diff --git a/.gitignore b/.gitignore index c5a2c135e..cdfed9175 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ # Maven # ######### target -\$\{env.JBOSS_HOME\} # OS generated files # ###################### diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 252825fd0..000000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: java - -# Enable container-based infrastructure, see https://docs.travis-ci.com/user/ci-environment/ -sudo: false diff --git a/core/jdiameter-ha/api/pom.xml b/core/jdiameter-ha/api/pom.xml index 9bd4e4002..7aa824511 100644 --- a/core/jdiameter-ha/api/pom.xml +++ b/core/jdiameter-ha/api/pom.xml @@ -20,8 +20,6 @@ - - - - - - - org.restcomm.cluster + org.mobicents.cluster timers diff --git a/core/jdiameter-ha/impl/pom.xml b/core/jdiameter-ha/impl/pom.xml index 68d5239a6..a15b5fe82 100644 --- a/core/jdiameter-ha/impl/pom.xml +++ b/core/jdiameter-ha/impl/pom.xml @@ -25,33 +25,26 @@ jdiameter-impl - - + - org.jboss.cluster - jboss-ha-server-cache-jbc + org.jboss.logging + jboss-logging-log4j + provided - - javax - javaee-api - 6.0 - - --> - - - org.restcomm.cluster - core + org.jboss.cluster + jboss-ha-server-cache-jbc - org.restcomm.cluster + org.mobicents.cluster cache - org.restcomm.cluster + org.mobicents.cluster timers diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/acc/ClientAccSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/acc/ClientAccSessionDataReplicatedImpl.java index 72abe060a..0b2b71df6 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/acc/ClientAccSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/acc/ClientAccSessionDataReplicatedImpl.java @@ -45,7 +45,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.AvpDataException; import org.jdiameter.api.Request; import org.jdiameter.api.acc.ClientAccSession; @@ -55,7 +55,7 @@ import org.jdiameter.client.api.parser.ParseException; import org.jdiameter.client.impl.app.acc.IClientAccSessionData; import org.jdiameter.common.api.app.acc.ClientAccSessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.slf4j.Logger; @@ -79,12 +79,12 @@ public class ClientAccSessionDataReplicatedImpl extends AppSessionDataReplicated private IMessageParser messageParser; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientAccSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public ClientAccSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientAccSession.class); @@ -97,13 +97,10 @@ public ClientAccSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCl /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientAccSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } /* @@ -115,7 +112,7 @@ public ClientAccSessionDataReplicatedImpl(String sessionId, MobicentsCluster mob @Override public void setClientAccSessionState(ClientAccSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -130,7 +127,7 @@ public void setClientAccSessionState(ClientAccSessionState state) { @Override public ClientAccSessionState getClientAccSessionState() { if (exists()) { - return (ClientAccSessionState) getNodeValue(STATE); + return (ClientAccSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -145,7 +142,7 @@ public ClientAccSessionState getClientAccSessionState() { @Override public void setInterimTimerId(Serializable tid) { if (exists()) { - putNodeValue(INTERIM_TIMERID, tid); + getNode().put(INTERIM_TIMERID, tid); } else { throw new IllegalStateException(); @@ -160,7 +157,7 @@ public void setInterimTimerId(Serializable tid) { @Override public Serializable getInterimTimerId() { if (exists()) { - return (Serializable) getNodeValue(INTERIM_TIMERID); + return (Serializable) getNode().get(INTERIM_TIMERID); } else { throw new IllegalStateException(); @@ -175,7 +172,7 @@ public Serializable getInterimTimerId() { @Override public void setDestinationHost(String destHost) { if (exists()) { - putNodeValue(DEST_HOST, destHost); + getNode().put(DEST_HOST, destHost); } else { throw new IllegalStateException(); @@ -190,7 +187,7 @@ public void setDestinationHost(String destHost) { @Override public String getDestinationHost() { if (exists()) { - return (String) getNodeValue(DEST_HOST); + return (String) getNode().get(DEST_HOST); } else { throw new IllegalStateException(); @@ -205,7 +202,7 @@ public String getDestinationHost() { @Override public void setDestinationRealm(String destRealm) { if (exists()) { - putNodeValue(DEST_REALM, destRealm); + getNode().put(DEST_REALM, destRealm); } else { throw new IllegalStateException(); @@ -220,7 +217,7 @@ public void setDestinationRealm(String destRealm) { @Override public String getDestinationRealm() { if (exists()) { - return (String) getNodeValue(DEST_REALM); + return (String) getNode().get(DEST_REALM); } else { throw new IllegalStateException(); @@ -229,7 +226,7 @@ public String getDestinationRealm() { @Override public Request getBuffer() { - byte[] data = (byte[]) getNodeValue(BUFFER); + byte[] data = (byte[]) getNode().get(BUFFER); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -249,14 +246,14 @@ public void setBuffer(Request buffer) { if (buffer != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - putNodeValue(BUFFER, data); + getNode().put(BUFFER, data); } catch (ParseException e) { logger.error("Unable to encode message to buffer."); } } else { - removeNodeValue(BUFFER); + getNode().remove(BUFFER); } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/auth/ClientAuthSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/auth/ClientAuthSessionDataReplicatedImpl.java index 43120a750..67dce12ae 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/auth/ClientAuthSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/auth/ClientAuthSessionDataReplicatedImpl.java @@ -44,11 +44,11 @@ import java.io.Serializable; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.auth.ClientAuthSession; import org.jdiameter.client.impl.app.auth.IClientAuthSessionData; import org.jdiameter.common.api.app.auth.ClientAuthSessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -66,11 +66,12 @@ public class ClientAuthSessionDataReplicatedImpl extends AppSessionDataReplicate private static final String TS_TIMERID = "TS_TIMERID"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ClientAuthSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ClientAuthSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientAuthSession.class); @@ -81,12 +82,10 @@ public ClientAuthSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsC /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ClientAuthSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -98,7 +97,7 @@ public ClientAuthSessionDataReplicatedImpl(String sessionId, MobicentsCluster mo @Override public void setClientAuthSessionState(ClientAuthSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -113,7 +112,7 @@ public void setClientAuthSessionState(ClientAuthSessionState state) { @Override public ClientAuthSessionState getClientAuthSessionState() { if (exists()) { - return (ClientAuthSessionState) getNodeValue(STATE); + return (ClientAuthSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -128,7 +127,7 @@ public ClientAuthSessionState getClientAuthSessionState() { @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); @@ -143,7 +142,7 @@ public boolean isStateless() { @Override public void setStateless(boolean b) { if (exists()) { - putNodeValue(STATELESS, b); + getNode().put(STATELESS, b); } else { throw new IllegalStateException(); @@ -159,7 +158,7 @@ public void setStateless(boolean b) { @Override public String getDestinationHost() { if (exists()) { - return (String) getNodeValue(DESTINATION_HOST); + return (String) getNode().get(DESTINATION_HOST); } else { throw new IllegalStateException(); @@ -174,7 +173,7 @@ public String getDestinationHost() { @Override public void setDestinationHost(String host) { if (exists()) { - putNodeValue(DESTINATION_HOST, host); + getNode().put(DESTINATION_HOST, host); } else { throw new IllegalStateException(); @@ -189,7 +188,7 @@ public void setDestinationHost(String host) { @Override public String getDestinationRealm() { if (exists()) { - return (String) getNodeValue(DESTINATION_REALM); + return (String) getNode().get(DESTINATION_REALM); } else { throw new IllegalStateException(); @@ -204,7 +203,7 @@ public String getDestinationRealm() { @Override public void setDestinationRealm(String realm) { if (exists()) { - putNodeValue(DESTINATION_REALM, realm); + getNode().put(DESTINATION_REALM, realm); } else { throw new IllegalStateException(); @@ -219,7 +218,7 @@ public void setDestinationRealm(String realm) { @Override public Serializable getTsTimerId() { if (exists()) { - return (Serializable) getNodeValue(TS_TIMERID); + return (Serializable) getNode().get(TS_TIMERID); } else { throw new IllegalStateException(); @@ -234,7 +233,7 @@ public Serializable getTsTimerId() { @Override public void setTsTimerId(Serializable tid) { if (exists()) { - putNodeValue(TS_TIMERID, tid); + getNode().put(TS_TIMERID, tid); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cca/ClientCCASessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cca/ClientCCASessionDataReplicatedImpl.java index eced8d49c..f0bb81db0 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cca/ClientCCASessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cca/ClientCCASessionDataReplicatedImpl.java @@ -45,7 +45,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.AvpDataException; import org.jdiameter.api.Request; import org.jdiameter.api.cca.ClientCCASession; @@ -55,7 +55,7 @@ import org.jdiameter.client.api.parser.ParseException; import org.jdiameter.client.impl.app.cca.IClientCCASessionData; import org.jdiameter.common.api.app.cca.ClientCCASessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.slf4j.Logger; @@ -83,12 +83,12 @@ public class ClientCCASessionDataReplicatedImpl extends AppSessionDataReplicated private IMessageParser messageParser; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientCCASessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public ClientCCASessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientCCASession.class); @@ -101,19 +101,16 @@ public ClientCCASessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCl /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientCCASessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } @Override public boolean isEventBased() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(EVENT_BASED), true); + return toPrimitive((Boolean) getNode().get(EVENT_BASED), true); } else { throw new IllegalStateException(); @@ -123,7 +120,7 @@ public boolean isEventBased() { @Override public void setEventBased(boolean isEventBased) { if (exists()) { - putNodeValue(EVENT_BASED, isEventBased); + getNode().put(EVENT_BASED, isEventBased); } else { throw new IllegalStateException(); @@ -133,7 +130,7 @@ public void setEventBased(boolean isEventBased) { @Override public boolean isRequestTypeSet() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(REQUEST_TYPE), false); + return toPrimitive((Boolean) getNode().get(REQUEST_TYPE), false); } else { throw new IllegalStateException(); @@ -143,7 +140,7 @@ public boolean isRequestTypeSet() { @Override public void setRequestTypeSet(boolean requestTypeSet) { if (exists()) { - putNodeValue(REQUEST_TYPE, requestTypeSet); + getNode().put(REQUEST_TYPE, requestTypeSet); } else { throw new IllegalStateException(); @@ -153,7 +150,7 @@ public void setRequestTypeSet(boolean requestTypeSet) { @Override public ClientCCASessionState getClientCCASessionState() { if (exists()) { - return (ClientCCASessionState) getNodeValue(STATE); + return (ClientCCASessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -163,7 +160,7 @@ public ClientCCASessionState getClientCCASessionState() { @Override public void setClientCCASessionState(ClientCCASessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -173,7 +170,7 @@ public void setClientCCASessionState(ClientCCASessionState state) { @Override public Serializable getTxTimerId() { if (exists()) { - return (Serializable) getNodeValue(TXTIMER_ID); + return (Serializable) getNode().get(TXTIMER_ID); } else { throw new IllegalStateException(); @@ -183,7 +180,7 @@ public Serializable getTxTimerId() { @Override public void setTxTimerId(Serializable txTimerId) { if (exists()) { - putNodeValue(TXTIMER_ID, txTimerId); + getNode().put(TXTIMER_ID, txTimerId); } else { throw new IllegalStateException(); @@ -194,7 +191,7 @@ public void setTxTimerId(Serializable txTimerId) { public Request getTxTimerRequest() { if (exists()) { - byte[] data = (byte[]) getNodeValue(TXTIMER_REQUEST); + byte[] data = (byte[]) getNode().get(TXTIMER_REQUEST); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -219,14 +216,14 @@ public void setTxTimerRequest(Request txTimerRequest) { if (txTimerRequest != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) txTimerRequest).array(); - putNodeValue(TXTIMER_REQUEST, data); + getNode().put(TXTIMER_REQUEST, data); } catch (ParseException e) { logger.error("Unable to encode Tx Timer Request to buffer."); } } else { - removeNodeValue(TXTIMER_REQUEST); + getNode().remove(TXTIMER_REQUEST); } } else { @@ -236,7 +233,7 @@ public void setTxTimerRequest(Request txTimerRequest) { @Override public Request getBuffer() { - byte[] data = (byte[]) getNodeValue(BUFFER); + byte[] data = (byte[]) getNode().get(BUFFER); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -256,21 +253,21 @@ public void setBuffer(Request buffer) { if (buffer != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - putNodeValue(BUFFER, data); + getNode().put(BUFFER, data); } catch (ParseException e) { logger.error("Unable to encode message to buffer."); } } else { - removeNodeValue(BUFFER); + getNode().remove(BUFFER); } } @Override public int getGatheredRequestedAction() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GRA)); + return toPrimitive((Integer) getNode().get(GRA)); } else { throw new IllegalStateException(); @@ -280,7 +277,7 @@ public int getGatheredRequestedAction() { @Override public void setGatheredRequestedAction(int gatheredRequestedAction) { if (exists()) { - putNodeValue(GRA, gatheredRequestedAction); + getNode().put(GRA, gatheredRequestedAction); } else { throw new IllegalStateException(); @@ -290,7 +287,7 @@ public void setGatheredRequestedAction(int gatheredRequestedAction) { @Override public int getGatheredCCFH() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GCCFH)); + return toPrimitive((Integer) getNode().get(GCCFH)); } else { throw new IllegalStateException(); @@ -300,7 +297,7 @@ public int getGatheredCCFH() { @Override public void setGatheredCCFH(int gatheredCCFH) { if (exists()) { - putNodeValue(GCCFH, gatheredCCFH); + getNode().put(GCCFH, gatheredCCFH); } else { throw new IllegalStateException(); @@ -310,7 +307,7 @@ public void setGatheredCCFH(int gatheredCCFH) { @Override public int getGatheredDDFH() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GDDFH)); + return toPrimitive((Integer) getNode().get(GDDFH)); } else { throw new IllegalStateException(); @@ -320,7 +317,7 @@ public int getGatheredDDFH() { @Override public void setGatheredDDFH(int gatheredDDFH) { if (exists()) { - putNodeValue(GDDFH, gatheredDDFH); + getNode().put(GDDFH, gatheredDDFH); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cxdx/ClientCxDxSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cxdx/ClientCxDxSessionDataReplicatedImpl.java index 886894b9e..2ce7d8f29 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cxdx/ClientCxDxSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/cxdx/ClientCxDxSessionDataReplicatedImpl.java @@ -42,12 +42,12 @@ package org.mobicents.diameter.impl.ha.client.cxdx; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.cxdx.ClientCxDxSession; import org.jdiameter.client.api.IContainer; import org.jdiameter.client.impl.app.cxdx.IClientCxDxSessionData; import org.jdiameter.common.api.app.cxdx.CxDxSessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.cxdx.CxDxSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -59,12 +59,12 @@ public class ClientCxDxSessionDataReplicatedImpl extends CxDxSessionDataReplicatedImpl implements IClientCxDxSessionData { /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientCxDxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster, container); + public ClientCxDxSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); if (super.create()) { setAppSessionIface(this, ClientCxDxSession.class); @@ -75,13 +75,10 @@ public ClientCxDxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsC /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientCxDxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/gx/ClientGxSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/gx/ClientGxSessionDataReplicatedImpl.java index 177276119..bb9761e41 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/gx/ClientGxSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/gx/ClientGxSessionDataReplicatedImpl.java @@ -45,7 +45,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.AvpDataException; import org.jdiameter.api.Request; import org.jdiameter.api.gx.ClientGxSession; @@ -55,7 +55,7 @@ import org.jdiameter.client.api.parser.ParseException; import org.jdiameter.client.impl.app.gx.IClientGxSessionData; import org.jdiameter.common.api.app.gx.ClientGxSessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.slf4j.Logger; @@ -83,12 +83,12 @@ public class ClientGxSessionDataReplicatedImpl extends AppSessionDataReplicatedI private IMessageParser messageParser; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientGxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public ClientGxSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientGxSession.class); @@ -101,19 +101,16 @@ public ClientGxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientGxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } @Override public boolean isEventBased() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(EVENT_BASED), true); + return toPrimitive((Boolean) getNode().get(EVENT_BASED), true); } else { throw new IllegalStateException(); @@ -123,7 +120,7 @@ public boolean isEventBased() { @Override public void setEventBased(boolean isEventBased) { if (exists()) { - putNodeValue(EVENT_BASED, isEventBased); + getNode().put(EVENT_BASED, isEventBased); } else { throw new IllegalStateException(); @@ -133,7 +130,7 @@ public void setEventBased(boolean isEventBased) { @Override public boolean isRequestTypeSet() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(REQUEST_TYPE), false); + return toPrimitive((Boolean) getNode().get(REQUEST_TYPE), false); } else { throw new IllegalStateException(); @@ -143,7 +140,7 @@ public boolean isRequestTypeSet() { @Override public void setRequestTypeSet(boolean requestTypeSet) { if (exists()) { - putNodeValue(REQUEST_TYPE, requestTypeSet); + getNode().put(REQUEST_TYPE, requestTypeSet); } else { throw new IllegalStateException(); @@ -153,7 +150,7 @@ public void setRequestTypeSet(boolean requestTypeSet) { @Override public ClientGxSessionState getClientGxSessionState() { if (exists()) { - return (ClientGxSessionState) getNodeValue(STATE); + return (ClientGxSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -163,7 +160,7 @@ public ClientGxSessionState getClientGxSessionState() { @Override public void setClientGxSessionState(ClientGxSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -173,7 +170,7 @@ public void setClientGxSessionState(ClientGxSessionState state) { @Override public Serializable getTxTimerId() { if (exists()) { - return (Serializable) getNodeValue(TXTIMER_ID); + return (Serializable) getNode().get(TXTIMER_ID); } else { throw new IllegalStateException(); @@ -183,7 +180,7 @@ public Serializable getTxTimerId() { @Override public void setTxTimerId(Serializable txTimerId) { if (exists()) { - putNodeValue(TXTIMER_ID, txTimerId); + getNode().put(TXTIMER_ID, txTimerId); } else { throw new IllegalStateException(); @@ -194,7 +191,7 @@ public void setTxTimerId(Serializable txTimerId) { public Request getTxTimerRequest() { if (exists()) { - byte[] data = (byte[]) getNodeValue(TXTIMER_REQUEST); + byte[] data = (byte[]) getNode().get(TXTIMER_REQUEST); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -221,14 +218,14 @@ public void setTxTimerRequest(Request txTimerRequest) { try { byte[] data = this.messageParser.encodeMessage((IMessage) txTimerRequest).array(); - putNodeValue(TXTIMER_REQUEST, data); + getNode().put(TXTIMER_REQUEST, data); } catch (ParseException e) { logger.error("Unable to encode Tx Timer Request to buffer."); } } else { - removeNodeValue(TXTIMER_REQUEST); + getNode().remove(TXTIMER_REQUEST); } } else { @@ -238,7 +235,7 @@ public void setTxTimerRequest(Request txTimerRequest) { @Override public Request getBuffer() { - byte[] data = (byte[]) getNodeValue(BUFFER); + byte[] data = (byte[]) getNode().get(BUFFER); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -258,21 +255,21 @@ public void setBuffer(Request buffer) { if (buffer != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - putNodeValue(BUFFER, data); + getNode().put(BUFFER, data); } catch (ParseException e) { logger.error("Unable to encode message to buffer."); } } else { - removeNodeValue(BUFFER); + getNode().remove(BUFFER); } } @Override public int getGatheredRequestedAction() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GRA)); + return toPrimitive((Integer) getNode().get(GRA)); } else { throw new IllegalStateException(); @@ -282,7 +279,7 @@ public int getGatheredRequestedAction() { @Override public void setGatheredRequestedAction(int gatheredRequestedAction) { if (exists()) { - putNodeValue(GRA, gatheredRequestedAction); + getNode().put(GRA, gatheredRequestedAction); } else { throw new IllegalStateException(); @@ -292,7 +289,7 @@ public void setGatheredRequestedAction(int gatheredRequestedAction) { @Override public int getGatheredCCFH() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GCCFH)); + return toPrimitive((Integer) getNode().get(GCCFH)); } else { throw new IllegalStateException(); @@ -302,7 +299,7 @@ public int getGatheredCCFH() { @Override public void setGatheredCCFH(int gatheredCCFH) { if (exists()) { - putNodeValue(GCCFH, gatheredCCFH); + getNode().put(GCCFH, gatheredCCFH); } else { throw new IllegalStateException(); @@ -312,7 +309,7 @@ public void setGatheredCCFH(int gatheredCCFH) { @Override public int getGatheredDDFH() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GDDFH)); + return toPrimitive((Integer) getNode().get(GDDFH)); } else { throw new IllegalStateException(); @@ -322,7 +319,7 @@ public int getGatheredDDFH() { @Override public void setGatheredDDFH(int gatheredDDFH) { if (exists()) { - putNodeValue(GDDFH, gatheredDDFH); + getNode().put(GDDFH, gatheredDDFH); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rf/ClientRfSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rf/ClientRfSessionDataReplicatedImpl.java index 32cf7dd0d..ab9a92c68 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rf/ClientRfSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rf/ClientRfSessionDataReplicatedImpl.java @@ -45,7 +45,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.AvpDataException; import org.jdiameter.api.Request; import org.jdiameter.api.rf.ClientRfSession; @@ -55,7 +55,7 @@ import org.jdiameter.client.api.parser.ParseException; import org.jdiameter.client.impl.app.rf.IClientRfSessionData; import org.jdiameter.common.api.app.rf.ClientRfSessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.slf4j.Logger; @@ -79,12 +79,12 @@ public class ClientRfSessionDataReplicatedImpl extends AppSessionDataReplicatedI private IMessageParser messageParser; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientRfSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public ClientRfSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientRfSession.class); @@ -97,19 +97,16 @@ public ClientRfSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientRfSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } @Override public ClientRfSessionState getClientRfSessionState() { if (exists()) { - return (ClientRfSessionState) getNodeValue(STATE); + return (ClientRfSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -119,7 +116,7 @@ public ClientRfSessionState getClientRfSessionState() { @Override public void setClientRfSessionState(ClientRfSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -128,7 +125,7 @@ public void setClientRfSessionState(ClientRfSessionState state) { @Override public Request getBuffer() { - byte[] data = (byte[]) getNodeValue(BUFFER); + byte[] data = (byte[]) getNode().get(BUFFER); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -149,14 +146,14 @@ public void setBuffer(Request buffer) { try { byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - putNodeValue(BUFFER, data); + getNode().put(BUFFER, data); } catch (ParseException e) { logger.error("Unable to encode message to buffer."); } } else { - removeNodeValue(BUFFER); + getNode().remove(BUFFER); } } @@ -168,7 +165,7 @@ public void setBuffer(Request buffer) { @Override public Serializable getTsTimerId() { if (exists()) { - return (Serializable) getNodeValue(TS_TIMERID); + return (Serializable) getNode().get(TS_TIMERID); } else { throw new IllegalStateException(); @@ -183,7 +180,7 @@ public Serializable getTsTimerId() { @Override public void setTsTimerId(Serializable tid) { if (exists()) { - putNodeValue(TS_TIMERID, tid); + getNode().put(TS_TIMERID, tid); } else { throw new IllegalStateException(); @@ -198,7 +195,7 @@ public void setTsTimerId(Serializable tid) { @Override public String getDestinationHost() { if (exists()) { - return (String) getNodeValue(DESTINATION_HOST); + return (String) getNode().get(DESTINATION_HOST); } else { throw new IllegalStateException(); @@ -213,7 +210,7 @@ public String getDestinationHost() { @Override public void setDestinationHost(String destinationHost) { if (exists()) { - putNodeValue(DESTINATION_HOST, destinationHost); + getNode().put(DESTINATION_HOST, destinationHost); } else { throw new IllegalStateException(); @@ -228,7 +225,7 @@ public void setDestinationHost(String destinationHost) { @Override public String getDestinationRealm() { if (exists()) { - return (String) getNodeValue(DESTINATION_REALM); + return (String) getNode().get(DESTINATION_REALM); } else { throw new IllegalStateException(); @@ -243,7 +240,7 @@ public String getDestinationRealm() { @Override public void setDestinationRealm(String destinationRealm) { if (exists()) { - putNodeValue(DESTINATION_REALM, destinationRealm); + getNode().put(DESTINATION_REALM, destinationRealm); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/ro/ClientRoSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/ro/ClientRoSessionDataReplicatedImpl.java index 87486bdff..f1a150ac0 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/ro/ClientRoSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/ro/ClientRoSessionDataReplicatedImpl.java @@ -45,7 +45,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.AvpDataException; import org.jdiameter.api.Request; import org.jdiameter.api.ro.ClientRoSession; @@ -55,7 +55,7 @@ import org.jdiameter.client.api.parser.ParseException; import org.jdiameter.client.impl.app.ro.IClientRoSessionData; import org.jdiameter.common.api.app.ro.ClientRoSessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.slf4j.Logger; @@ -83,12 +83,12 @@ public class ClientRoSessionDataReplicatedImpl extends AppSessionDataReplicatedI private IMessageParser messageParser; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientRoSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public ClientRoSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientRoSession.class); @@ -101,19 +101,16 @@ public ClientRoSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientRoSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } @Override public boolean isEventBased() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(EVENT_BASED), true); + return toPrimitive((Boolean) getNode().get(EVENT_BASED), true); } else { throw new IllegalStateException(); @@ -123,7 +120,7 @@ public boolean isEventBased() { @Override public void setEventBased(boolean isEventBased) { if (exists()) { - putNodeValue(EVENT_BASED, isEventBased); + getNode().put(EVENT_BASED, isEventBased); } else { throw new IllegalStateException(); @@ -133,7 +130,7 @@ public void setEventBased(boolean isEventBased) { @Override public boolean isRequestTypeSet() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(REQUEST_TYPE), false); + return toPrimitive((Boolean) getNode().get(REQUEST_TYPE), false); } else { throw new IllegalStateException(); @@ -143,7 +140,7 @@ public boolean isRequestTypeSet() { @Override public void setRequestTypeSet(boolean requestTypeSet) { if (exists()) { - putNodeValue(REQUEST_TYPE, requestTypeSet); + getNode().put(REQUEST_TYPE, requestTypeSet); } else { throw new IllegalStateException(); @@ -153,7 +150,7 @@ public void setRequestTypeSet(boolean requestTypeSet) { @Override public ClientRoSessionState getClientRoSessionState() { if (exists()) { - return (ClientRoSessionState) getNodeValue(STATE); + return (ClientRoSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -163,7 +160,7 @@ public ClientRoSessionState getClientRoSessionState() { @Override public void setClientRoSessionState(ClientRoSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -173,7 +170,7 @@ public void setClientRoSessionState(ClientRoSessionState state) { @Override public Serializable getTxTimerId() { if (exists()) { - return (Serializable) getNodeValue(TXTIMER_ID); + return (Serializable) getNode().get(TXTIMER_ID); } else { throw new IllegalStateException(); @@ -183,7 +180,7 @@ public Serializable getTxTimerId() { @Override public void setTxTimerId(Serializable txTimerId) { if (exists()) { - putNodeValue(TXTIMER_ID, txTimerId); + getNode().put(TXTIMER_ID, txTimerId); } else { throw new IllegalStateException(); @@ -193,7 +190,7 @@ public void setTxTimerId(Serializable txTimerId) { @Override public Request getTxTimerRequest() { if (exists()) { - byte[] data = (byte[]) getNodeValue(TXTIMER_REQUEST); + byte[] data = (byte[]) getNode().get(TXTIMER_REQUEST); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -218,14 +215,14 @@ public void setTxTimerRequest(Request txTimerRequest) { if (txTimerRequest != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) txTimerRequest).array(); - putNodeValue(TXTIMER_REQUEST, data); + getNode().put(TXTIMER_REQUEST, data); } catch (ParseException e) { logger.error("Unable to encode Tx Timer Request to buffer."); } } else { - removeNodeValue(TXTIMER_REQUEST); + getNode().remove(TXTIMER_REQUEST); } } else { @@ -235,7 +232,7 @@ public void setTxTimerRequest(Request txTimerRequest) { @Override public Request getBuffer() { - byte[] data = (byte[]) getNodeValue(BUFFER); + byte[] data = (byte[]) getNode().get(BUFFER); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -255,21 +252,21 @@ public void setBuffer(Request buffer) { if (buffer != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - putNodeValue(BUFFER, data); + getNode().put(BUFFER, data); } catch (ParseException e) { logger.error("Unable to encode message to buffer."); } } else { - removeNodeValue(BUFFER); + getNode().remove(BUFFER); } } @Override public int getGatheredRequestedAction() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GRA)); + return toPrimitive((Integer) getNode().get(GRA)); } else { throw new IllegalStateException(); @@ -279,7 +276,7 @@ public int getGatheredRequestedAction() { @Override public void setGatheredRequestedAction(int gatheredRequestedAction) { if (exists()) { - putNodeValue(GRA, gatheredRequestedAction); + getNode().put(GRA, gatheredRequestedAction); } else { throw new IllegalStateException(); @@ -289,7 +286,7 @@ public void setGatheredRequestedAction(int gatheredRequestedAction) { @Override public int getGatheredCCFH() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GCCFH)); + return toPrimitive((Integer) getNode().get(GCCFH)); } else { throw new IllegalStateException(); @@ -299,7 +296,7 @@ public int getGatheredCCFH() { @Override public void setGatheredCCFH(int gatheredCCFH) { if (exists()) { - putNodeValue(GCCFH, gatheredCCFH); + getNode().put(GCCFH, gatheredCCFH); } else { throw new IllegalStateException(); @@ -309,7 +306,7 @@ public void setGatheredCCFH(int gatheredCCFH) { @Override public int getGatheredDDFH() { if (exists()) { - return toPrimitive((Integer) getNodeValue(GDDFH)); + return toPrimitive((Integer) getNode().get(GDDFH)); } else { throw new IllegalStateException(); @@ -319,7 +316,7 @@ public int getGatheredDDFH() { @Override public void setGatheredDDFH(int gatheredDDFH) { if (exists()) { - putNodeValue(GDDFH, gatheredDDFH); + getNode().put(GDDFH, gatheredDDFH); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rx/ClientRxSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rx/ClientRxSessionDataReplicatedImpl.java index 5434b524a..74ca87c46 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rx/ClientRxSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/rx/ClientRxSessionDataReplicatedImpl.java @@ -42,12 +42,12 @@ package org.mobicents.diameter.impl.ha.client.rx; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.rx.ClientRxSession; import org.jdiameter.client.api.IContainer; import org.jdiameter.client.impl.app.rx.IClientRxSessionData; import org.jdiameter.common.api.app.rx.ClientRxSessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -63,12 +63,12 @@ public class ClientRxSessionDataReplicatedImpl extends AppSessionDataReplicatedI private static final String STATE = "STATE"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientRxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public ClientRxSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientRxSession.class); @@ -79,19 +79,16 @@ public ClientRxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientRxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } @Override public boolean isEventBased() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(EVENT_BASED), true); + return toPrimitive((Boolean) getNode().get(EVENT_BASED), true); } else { throw new IllegalStateException(); } @@ -100,7 +97,7 @@ public boolean isEventBased() { @Override public void setEventBased(boolean isEventBased) { if (exists()) { - putNodeValue(EVENT_BASED, isEventBased); + getNode().put(EVENT_BASED, isEventBased); } else { throw new IllegalStateException(); } @@ -109,7 +106,7 @@ public void setEventBased(boolean isEventBased) { @Override public boolean isRequestTypeSet() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(REQUEST_TYPE), false); + return toPrimitive((Boolean) getNode().get(REQUEST_TYPE), false); } else { throw new IllegalStateException(); } @@ -118,7 +115,7 @@ public boolean isRequestTypeSet() { @Override public void setRequestTypeSet(boolean requestTypeSet) { if (exists()) { - putNodeValue(REQUEST_TYPE, requestTypeSet); + getNode().put(REQUEST_TYPE, requestTypeSet); } else { throw new IllegalStateException(); } @@ -127,7 +124,7 @@ public void setRequestTypeSet(boolean requestTypeSet) { @Override public ClientRxSessionState getClientRxSessionState() { if (exists()) { - return (ClientRxSessionState) getNodeValue(STATE); + return (ClientRxSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); } @@ -136,7 +133,7 @@ public ClientRxSessionState getClientRxSessionState() { @Override public void setClientRxSessionState(ClientRxSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/s13/ClientS13SessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/s13/ClientS13SessionDataReplicatedImpl.java index 4b0d8eaab..52a7d935e 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/s13/ClientS13SessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/s13/ClientS13SessionDataReplicatedImpl.java @@ -19,12 +19,12 @@ package org.mobicents.diameter.impl.ha.client.s13; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.s13.ClientS13Session; import org.jdiameter.client.api.IContainer; import org.jdiameter.client.impl.app.s13.IClientS13SessionData; import org.jdiameter.common.api.app.s13.S13SessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.s13.S13SessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -36,12 +36,12 @@ public class ClientS13SessionDataReplicatedImpl extends S13SessionDataReplicatedImpl implements IClientS13SessionData { /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ClientS13SessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster, container); + public ClientS13SessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); if (super.create()) { setAppSessionIface(this, ClientS13Session.class); @@ -52,13 +52,10 @@ public ClientS13SessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCl /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ClientS13SessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/sh/ShClientSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/sh/ShClientSessionDataReplicatedImpl.java index d601d3fea..8172f55cd 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/sh/ShClientSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/sh/ShClientSessionDataReplicatedImpl.java @@ -42,10 +42,10 @@ package org.mobicents.diameter.impl.ha.client.sh; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.sh.ClientShSession; import org.jdiameter.client.impl.app.sh.IShClientSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -57,11 +57,12 @@ public class ShClientSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements IShClientSessionData { /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ShClientSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ShClientSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ClientShSession.class); @@ -71,12 +72,10 @@ public ShClientSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ShClientSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java new file mode 100644 index 000000000..4cb86bc76 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java @@ -0,0 +1,64 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.client.slg; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.impl.app.slg.IClientSLgSessionData; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slg.SLgSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ClientSLgSessionDataReplicatedImpl extends SLgSessionDataReplicatedImpl implements IClientSLgSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param container + */ + public ClientSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ClientSLgSession.class); + setSLgSessionState(SLgSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param container + */ + public ClientSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} + diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java new file mode 100644 index 000000000..40aa996ff --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java @@ -0,0 +1,63 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.client.slh; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.impl.app.slh.IClientSLhSessionData; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slh.SLhSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ClientSLhSessionDataReplicatedImpl extends SLhSessionDataReplicatedImpl implements IClientSLhSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param container + */ + public ClientSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ClientSLhSession.class); + setSLhSessionState(SLhSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param container + */ + public ClientSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/AppSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/AppSessionDataReplicatedImpl.java index dceacc77b..56ba70d3d 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/AppSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/AppSessionDataReplicatedImpl.java @@ -42,13 +42,14 @@ package org.mobicents.diameter.impl.ha.common; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; +import org.jboss.cache.Node; import org.jdiameter.api.ApplicationId; import org.jdiameter.api.app.AppSession; import org.jdiameter.common.api.app.IAppSessionData; -import org.restcomm.cache.MobicentsCache; -import org.restcomm.cluster.MobicentsCluster; -import org.restcomm.cluster.cache.ClusteredCacheData; +import org.mobicents.cache.MobicentsCache; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.cluster.cache.ClusteredCacheData; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; /** @@ -63,42 +64,36 @@ public class AppSessionDataReplicatedImpl extends ClusteredCacheData implements protected static final String SIFACE = "SIFACE"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster */ - public AppSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public AppSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); } public AppSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } public static void setAppSessionIface(ClusteredCacheData ccd, Class iface) { - ccd.getMobicentsCache().putCacheNodeValue(ccd.getNodeFqnWrapper(), SIFACE, iface); + Node n = ccd.getMobicentsCache().getJBossCache().getNode(ccd.getNodeFqn()); + n.put(SIFACE, iface); } public static Class getAppSessionIface(MobicentsCache mcCache, String sessionId) { - @SuppressWarnings("unchecked") - Class value = (Class) mcCache.getCacheNodeValue( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - SIFACE - ); - return value; + Node n = mcCache.getJBossCache().getNode(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId)); + return (Class) n.get(SIFACE); } @Override public String getSessionId() { - return (String) super.getNodeFqnLastElement(); + return (String) super.getNodeFqn().getLastElement(); } @Override public void setApplicationId(ApplicationId applicationId) { if (exists()) { - putNodeValue(APID, applicationId); + getNode().put(APID, applicationId); } else { throw new IllegalStateException(); @@ -108,7 +103,7 @@ public void setApplicationId(ApplicationId applicationId) { @Override public ApplicationId getApplicationId() { if (exists()) { - return (ApplicationId) getNodeValue(APID); + return (ApplicationId) getNode().get(APID); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/acc/AccReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/acc/AccReplicatedSessionDataFactory.java index c051a2d83..6efc94304 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/acc/AccReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/acc/AccReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.acc.IAccSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.acc.ClientAccSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.acc.ServerAccSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/auth/AuthReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/auth/AuthReplicatedSessionDataFactory.java index 583c4139e..9f5e73296 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/auth/AuthReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/auth/AuthReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.auth.IAuthSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.auth.ClientAuthSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.auth.ServerAuthSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cca/CCAReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cca/CCAReplicatedSessionDataFactory.java index 893620001..b603fe779 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cca/CCAReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cca/CCAReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.cca.ICCASessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.cca.ClientCCASessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.cca.ServerCCASessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxReplicatedSessionDataFactory.java index bfbda64ae..62ea766ca 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.cxdx.ICxDxSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.cxdx.ClientCxDxSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.cxdx.ServerCxDxSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxSessionDataReplicatedImpl.java index 5668a52c0..6a167ab19 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/cxdx/CxDxSessionDataReplicatedImpl.java @@ -45,7 +45,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.AvpDataException; import org.jdiameter.api.Request; import org.jdiameter.client.api.IContainer; @@ -54,7 +54,7 @@ import org.jdiameter.client.api.parser.ParseException; import org.jdiameter.common.api.app.cxdx.CxDxSessionState; import org.jdiameter.common.api.app.cxdx.ICxDxSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,12 +75,12 @@ public abstract class CxDxSessionDataReplicatedImpl extends AppSessionDataReplic private IMessageParser messageParser; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public CxDxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public CxDxSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); } @@ -92,7 +92,7 @@ public CxDxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster @Override public void setCxDxSessionState(CxDxSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -107,7 +107,7 @@ public void setCxDxSessionState(CxDxSessionState state) { @Override public CxDxSessionState getCxDxSessionState() { if (exists()) { - return (CxDxSessionState) getNodeValue(STATE); + return (CxDxSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -122,7 +122,7 @@ public CxDxSessionState getCxDxSessionState() { @Override public Serializable getTsTimerId() { if (exists()) { - return (Serializable) getNodeValue(TS_TIMERID); + return (Serializable) getNode().get(TS_TIMERID); } else { throw new IllegalStateException(); @@ -137,7 +137,7 @@ public Serializable getTsTimerId() { @Override public void setTsTimerId(Serializable tid) { if (exists()) { - putNodeValue(TS_TIMERID, tid); + getNode().put(TS_TIMERID, tid); } else { throw new IllegalStateException(); @@ -146,7 +146,7 @@ public void setTsTimerId(Serializable tid) { @Override public Request getBuffer() { - byte[] data = (byte[]) getNodeValue(BUFFER); + byte[] data = (byte[]) getNode().get(BUFFER); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -166,14 +166,14 @@ public void setBuffer(Request buffer) { if (buffer != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - putNodeValue(BUFFER, data); + getNode().put(BUFFER, data); } catch (ParseException e) { logger.error("Unable to encode message to buffer."); } } else { - removeNodeValue(BUFFER); + getNode().remove(BUFFER); } } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/gx/GxReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/gx/GxReplicatedSessionDataFactory.java index 1a66a51cf..7729b240e 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/gx/GxReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/gx/GxReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.gx.IGxSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.gx.ClientGxSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.gx.ServerGxSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rf/RfReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rf/RfReplicatedSessionDataFactory.java index 951908d0a..a4b96f384 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rf/RfReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rf/RfReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.rf.IRfSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.rf.ClientRfSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.rf.ServerRfSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/ro/RoReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/ro/RoReplicatedSessionDataFactory.java index a3f4f4e64..d9ccb6bad 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/ro/RoReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/ro/RoReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.ro.IRoSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.ro.ClientRoSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.ro.ServerRoSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rx/RxReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rx/RxReplicatedSessionDataFactory.java index d7704e58b..726a12a73 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rx/RxReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/rx/RxReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.rx.IRxSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.rx.ClientRxSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.rx.ServerRxSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13ReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13ReplicatedSessionDataFactory.java index 3c0291153..8fb1cda2e 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13ReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13ReplicatedSessionDataFactory.java @@ -25,7 +25,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.s13.IS13SessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.s13.ClientS13SessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.s13.ServerS13SessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13SessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13SessionDataReplicatedImpl.java index d56fe7827..e75ad3194 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13SessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/s13/S13SessionDataReplicatedImpl.java @@ -22,7 +22,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.AvpDataException; import org.jdiameter.api.Request; import org.jdiameter.client.api.IContainer; @@ -31,7 +31,7 @@ import org.jdiameter.client.api.parser.ParseException; import org.jdiameter.common.api.app.s13.IS13SessionData; import org.jdiameter.common.api.app.s13.S13SessionState; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,12 +52,12 @@ public abstract class S13SessionDataReplicatedImpl extends AppSessionDataReplica private IMessageParser messageParser; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public S13SessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster); + public S13SessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); } @@ -69,7 +69,7 @@ public S13SessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster @Override public void setS13SessionState(S13SessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -84,7 +84,7 @@ public void setS13SessionState(S13SessionState state) { @Override public S13SessionState getS13SessionState() { if (exists()) { - return (S13SessionState) getNodeValue(STATE); + return (S13SessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -99,7 +99,7 @@ public S13SessionState getS13SessionState() { @Override public Serializable getTsTimerId() { if (exists()) { - return (Serializable) getNodeValue(TS_TIMERID); + return (Serializable) getNode().get(TS_TIMERID); } else { throw new IllegalStateException(); @@ -114,7 +114,7 @@ public Serializable getTsTimerId() { @Override public void setTsTimerId(Serializable tid) { if (exists()) { - putNodeValue(TS_TIMERID, tid); + getNode().put(TS_TIMERID, tid); } else { throw new IllegalStateException(); @@ -123,7 +123,7 @@ public void setTsTimerId(Serializable tid) { @Override public Request getBuffer() { - byte[] data = (byte[]) getNodeValue(BUFFER); + byte[] data = (byte[]) getNode().get(BUFFER); if (data != null) { try { return this.messageParser.createMessage(ByteBuffer.wrap(data)); @@ -143,14 +143,14 @@ public void setBuffer(Request buffer) { if (buffer != null) { try { byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - putNodeValue(BUFFER, data); + getNode().put(BUFFER, data); } catch (ParseException e) { logger.error("Unable to encode message to buffer."); } } else { - removeNodeValue(BUFFER); + getNode().remove(BUFFER); } } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/sh/ShReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/sh/ShReplicatedSessionDataFactory.java index bab353670..c01890200 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/sh/ShReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/sh/ShReplicatedSessionDataFactory.java @@ -48,7 +48,7 @@ import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.sh.IShSessionData; import org.jdiameter.common.api.data.ISessionDatasource; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.client.sh.ShClientSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; import org.mobicents.diameter.impl.ha.server.sh.ShServerSessionDataReplicatedImpl; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java new file mode 100644 index 000000000..ec5d31540 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java @@ -0,0 +1,72 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.common.slg; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.jdiameter.common.api.data.ISessionDatasource; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.client.slg.ClientSLgSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; +import org.mobicents.diameter.impl.ha.server.slg.ServerSLgSessionDataReplicatedImpl; + +/** + * + * @author Fernando Mendioroz + * + */ +public class SLgReplicatedSessionDataFactory implements IAppSessionDataFactory { + + private ReplicatedSessionDatasource replicatedSessionDataSource; + private MobicentsCluster mobicentsCluster; + + /** + * @param replicatedSessionDataSource + */ + public SLgReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? + super(); + this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; + this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) + */ + public ISLgSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLgSession.class)) { + ClientSLgSessionDataReplicatedImpl data = new ClientSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; + } else if (clazz.equals(ServerSLgSession.class)) { + ServerSLgSessionDataReplicatedImpl data = new ServerSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; + } + throw new IllegalArgumentException(); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java new file mode 100644 index 000000000..b399c0fa2 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java @@ -0,0 +1,149 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.common.slg; + +import java.io.Serializable; +import java.nio.ByteBuffer; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.Request; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.api.IMessage; +import org.jdiameter.client.api.parser.IMessageParser; +import org.jdiameter.client.api.parser.ParseException; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Fernando Mendioroz + * + */ +public abstract class SLgSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements ISLgSessionData { + + private static final Logger logger = LoggerFactory.getLogger(SLgSessionDataReplicatedImpl.class); + + private static final String STATE = "STATE"; + private static final String BUFFER = "BUFFER"; + private static final String TS_TIMERID = "TS_TIMERID"; + + private IMessageParser messageParser; + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param container + */ + public SLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); + this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setSLgSessionState(org.jdiameter.common.api.app.slg.SLgSessionState) + */ + public void setSLgSessionState(SLgSessionState state) { + if (exists()) { + getNode().put(STATE, state); + } else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getSLgSessionState() + */ + public SLgSessionState getSLgSessionState() { + if (exists()) { + return (SLgSessionState) getNode().get(STATE); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getTsTimerId() + */ + public Serializable getTsTimerId() { + if (exists()) { + return (Serializable) getNode().get(TS_TIMERID); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setTsTimerId(java.io.Serializable) + */ + public void setTsTimerId(Serializable tid) { + if (exists()) { + getNode().put(TS_TIMERID, tid); + } + else { + throw new IllegalStateException(); + } + } + + public Request getBuffer() { + byte[] data = (byte[]) getNode().get(BUFFER); + if (data != null) { + try { + return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); + } catch (AvpDataException e) { + logger.error("Unable to recreate message from buffer."); + return null; + } + } else { + return null; + } + } + + public void setBuffer(Request buffer) { + if (buffer != null) { + try { + byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); + getNode().put(BUFFER, data); + } + catch (ParseException e) { + logger.error("Unable to encode message to buffer."); + } + } + else { + getNode().remove(BUFFER); + } + } +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java new file mode 100644 index 000000000..954c4dc42 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java @@ -0,0 +1,72 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.common.slh; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.jdiameter.common.api.data.ISessionDatasource; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.client.slh.ClientSLhSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; +import org.mobicents.diameter.impl.ha.server.slh.ServerSLhSessionDataReplicatedImpl; + +/** + * + * @author Fernando Mendioroz + * + */ +public class SLhReplicatedSessionDataFactory implements IAppSessionDataFactory { + + private ReplicatedSessionDatasource replicatedSessionDataSource; + private MobicentsCluster mobicentsCluster; + + /** + * @param replicatedSessionDataSource + */ + public SLhReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? + super(); + this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; + this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) + */ + public ISLhSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLhSession.class)) { + ClientSLhSessionDataReplicatedImpl data = new ClientSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; + } else if (clazz.equals(ServerSLhSession.class)) { + ServerSLhSessionDataReplicatedImpl data = new ServerSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; + } + throw new IllegalArgumentException(); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java new file mode 100644 index 000000000..7babd3793 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java @@ -0,0 +1,149 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.common.slh; + +import java.io.Serializable; +import java.nio.ByteBuffer; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.Request; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.api.IMessage; +import org.jdiameter.client.api.parser.IMessageParser; +import org.jdiameter.client.api.parser.ParseException; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Fernando Mendioroz + * + */ +public abstract class SLhSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements ISLhSessionData { + + private static final Logger logger = LoggerFactory.getLogger(SLhSessionDataReplicatedImpl.class); + + private static final String STATE = "STATE"; + private static final String BUFFER = "BUFFER"; + private static final String TS_TIMERID = "TS_TIMERID"; + + private IMessageParser messageParser; + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param container + */ + public SLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); + this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setSLhSessionState(org.jdiameter.common.api.app.slh.SLhSessionState) + */ + public void setSLhSessionState(SLhSessionState state) { + if (exists()) { + getNode().put(STATE, state); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getSLhSessionState() + */ + public SLhSessionState getSLhSessionState() { + if (exists()) { + return (SLhSessionState) getNode().get(STATE); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getTsTimerId() + */ + public Serializable getTsTimerId() { + if (exists()) { + return (Serializable) getNode().get(TS_TIMERID); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setTsTimerId(java.io.Serializable) + */ + public void setTsTimerId(Serializable tid) { + if (exists()) { + getNode().put(TS_TIMERID, tid); + } + else { + throw new IllegalStateException(); + } + } + + public Request getBuffer() { + byte[] data = (byte[]) getNode().get(BUFFER); + if (data != null) { + try { + return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); + } catch (AvpDataException e) { + logger.error("Unable to recreate message from buffer."); + return null; + } + } else { + return null; + } + } + + public void setBuffer(Request buffer) { + if (buffer != null) { + try { + byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); + getNode().put(BUFFER, data); + } + catch (ParseException e) { + logger.error("Unable to encode message to buffer."); + } + } else { + getNode().remove(BUFFER); + } + } +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java index 1ca5eb44a..3c6874d5d 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java @@ -46,6 +46,7 @@ import javax.transaction.TransactionManager; +import org.jboss.cache.Fqn; import org.jdiameter.api.BaseSession; import org.jdiameter.api.IllegalDiameterStateException; import org.jdiameter.api.NetworkReqListener; @@ -65,14 +66,15 @@ import org.jdiameter.common.api.app.rx.IRxSessionData; import org.jdiameter.common.api.app.s13.IS13SessionData; import org.jdiameter.common.api.app.sh.IShSessionData; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.jdiameter.common.api.app.slg.ISLgSessionData; import org.jdiameter.common.api.data.ISessionDatasource; import org.jdiameter.common.impl.data.LocalDataSource; -import org.restcomm.cache.FqnWrapper; -import org.restcomm.cache.MobicentsCache; -import org.restcomm.cluster.DataRemovalListener; -import org.restcomm.cluster.DefaultMobicentsCluster; -import org.restcomm.cluster.MobicentsCluster; -import org.restcomm.cluster.election.DefaultClusterElector; +import org.mobicents.cache.MobicentsCache; +import org.mobicents.cluster.DataRemovalListener; +import org.mobicents.cluster.DefaultMobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.cluster.election.DefaultClusterElector; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.common.acc.AccReplicatedSessionDataFactory; import org.mobicents.diameter.impl.ha.common.auth.AuthReplicatedSessionDataFactory; @@ -84,6 +86,8 @@ import org.mobicents.diameter.impl.ha.common.rx.RxReplicatedSessionDataFactory; import org.mobicents.diameter.impl.ha.common.s13.S13ReplicatedSessionDataFactory; import org.mobicents.diameter.impl.ha.common.sh.ShReplicatedSessionDataFactory; +import org.mobicents.diameter.impl.ha.common.slh.SLhReplicatedSessionDataFactory; +import org.mobicents.diameter.impl.ha.common.slg.SLgReplicatedSessionDataFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,7 +100,7 @@ public class ReplicatedSessionDatasource implements ISessionDatasource, DataRemovalListener { private static final Logger logger = LoggerFactory.getLogger(ReplicatedSessionDatasource.class); - public static final String CLUSTER_DS_DEFAULT_FILE = "jdiameter-cache.xml"; + public static final String CLUSTER_DS_DEFAULT_FILE = "jdiameter-jbc.xml"; private IContainer container; private ISessionDatasource localDataSource; @@ -110,7 +114,7 @@ public class ReplicatedSessionDatasource implements ISessionDatasource, DataRemo // Constants // ---------------------------------------------------------------- public static final String SESSIONS = "/diameter/appsessions"; - public static final FqnWrapper SESSIONS_FQN = FqnWrapper.fromStringWrapper(SESSIONS); + public static final Fqn SESSIONS_FQN = Fqn.fromString(SESSIONS); public ReplicatedSessionDatasource(IContainer container) { this(container, new LocalDataSource(), ReplicatedSessionDatasource.class.getClassLoader().getResource(CLUSTER_DS_DEFAULT_FILE) == null ? @@ -121,23 +125,24 @@ public ReplicatedSessionDatasource(IContainer container, ISessionDatasource loca super(); this.localDataSource = localDataSource; - MobicentsCache mcCache = null; + MobicentsCache mcCache = new MobicentsCache(cacheConfigFilename); + TransactionManager txMgr = null; try { - mcCache = new MobicentsCache(cacheConfigFilename); - } catch (Exception e) { - logger.debug("Could not create MobicentsCache: ", e); + Class txMgrClass = Class.forName(mcCache.getJBossCache().getConfiguration().getTransactionManagerLookupClass()); + Object txMgrLookup = txMgrClass.getConstructor(new Class[]{}).newInstance(new Object[]{}); + txMgr = (TransactionManager) txMgrClass.getMethod("getTransactionManager", new Class[]{}).invoke(txMgrLookup, new Object[]{}); } - - TransactionManager txMgr = null; - if (mcCache != null) { - txMgr = mcCache.getTxManager(); + catch (Exception e) { + logger.debug("Could not fetch TxMgr. Not using one.", e); + // let's not have Tx Manager than... } + this.mobicentsCluster = new DefaultMobicentsCluster(mcCache, txMgr, new DefaultClusterElector()); this.mobicentsCluster.addDataRemovalListener(this); // register, so we know WHEN some other node removes session. this.mobicentsCluster.startCluster(); this.container = container; - // this is coded, its tied to specific impl of SessionDatasource + // this is coded, it's tied to specific impl of SessionDatasource appSessionDataFactories.put(IAuthSessionData.class, new AuthReplicatedSessionDataFactory(this)); appSessionDataFactories.put(IAccSessionData.class, new AccReplicatedSessionDataFactory(this)); appSessionDataFactories.put(ICCASessionData.class, new CCAReplicatedSessionDataFactory(this)); @@ -148,6 +153,8 @@ public ReplicatedSessionDatasource(IContainer container, ISessionDatasource loca appSessionDataFactories.put(IGxSessionData.class, new GxReplicatedSessionDataFactory(this)); appSessionDataFactories.put(IRxSessionData.class, new RxReplicatedSessionDataFactory(this)); appSessionDataFactories.put(IS13SessionData.class, new S13ReplicatedSessionDataFactory(this)); + appSessionDataFactories.put(ISLhSessionData.class, new SLhReplicatedSessionDataFactory(this)); + appSessionDataFactories.put(ISLgSessionData.class, new SLgReplicatedSessionDataFactory(this)); } @@ -294,13 +301,13 @@ public MobicentsCluster getMobicentsCluster() { } @Override - public void dataRemoved(FqnWrapper sessionFqn) { + public void dataRemoved(Fqn sessionFqn) { String sessionId = (String) sessionFqn.getLastElement(); this.localDataSource.removeSession(sessionId); } @Override - public FqnWrapper getBaseFqn() { + public Fqn getBaseFqn() { return SESSIONS_FQN; } @@ -309,9 +316,7 @@ public FqnWrapper getBaseFqn() { * @return */ private boolean existReplicated(String sessionId) { - if (!this.localMode && - this.mobicentsCluster.getMobicentsCache() - .getCacheNode(FqnWrapper.fromRelativeElementsWrapper(SESSIONS_FQN, sessionId)) != null) { + if (!this.localMode && this.mobicentsCluster.getMobicentsCache().getJBossCache().getNode(Fqn.fromRelativeElements(SESSIONS_FQN, sessionId)) != null) { return true; } return false; diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/acc/ServerAccSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/acc/ServerAccSessionDataReplicatedImpl.java index e1e11c9bc..0a20e90fe 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/acc/ServerAccSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/acc/ServerAccSessionDataReplicatedImpl.java @@ -44,11 +44,11 @@ import java.io.Serializable; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.acc.ServerAccSession; import org.jdiameter.common.api.app.acc.ServerAccSessionState; import org.jdiameter.server.impl.app.acc.IServerAccSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -65,11 +65,12 @@ public class ServerAccSessionDataReplicatedImpl extends AppSessionDataReplicated private static final String TS_TIMERID = "TS_TIMERID"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ServerAccSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ServerAccSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerAccSession.class); @@ -80,12 +81,10 @@ public ServerAccSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCl /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ServerAccSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -96,7 +95,7 @@ public ServerAccSessionDataReplicatedImpl(String sessionId, MobicentsCluster mob @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); @@ -111,7 +110,7 @@ public boolean isStateless() { @Override public void setStateless(boolean stateless) { if (exists()) { - putNodeValue(STATELESS, stateless); + getNode().put(STATELESS, stateless); } else { throw new IllegalStateException(); @@ -126,7 +125,7 @@ public void setStateless(boolean stateless) { @Override public ServerAccSessionState getServerAccSessionState() { if (exists()) { - return (ServerAccSessionState) getNodeValue(STATE); + return (ServerAccSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -142,7 +141,7 @@ public ServerAccSessionState getServerAccSessionState() { @Override public void setServerAccSessionState(ServerAccSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -152,7 +151,7 @@ public void setServerAccSessionState(ServerAccSessionState state) { @Override public void setTsTimeout(long value) { if (exists()) { - putNodeValue(TS_TIMEOUT, value); + getNode().put(TS_TIMEOUT, value); } else { throw new IllegalStateException(); @@ -162,7 +161,7 @@ public void setTsTimeout(long value) { @Override public long getTsTimeout() { if (exists()) { - return toPrimitive((Long) getNodeValue(TS_TIMEOUT)); + return toPrimitive((Long) getNode().get(TS_TIMEOUT)); } else { throw new IllegalStateException(); @@ -172,7 +171,7 @@ public long getTsTimeout() { @Override public void setTsTimerId(Serializable value) { if (exists()) { - putNodeValue(TS_TIMERID, value); + getNode().put(TS_TIMERID, value); } else { throw new IllegalStateException(); @@ -182,7 +181,7 @@ public void setTsTimerId(Serializable value) { @Override public Serializable getTsTimerId() { if (exists()) { - return (Serializable) getNodeValue(TS_TIMERID); + return (Serializable) getNode().get(TS_TIMERID); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/auth/ServerAuthSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/auth/ServerAuthSessionDataReplicatedImpl.java index 3c25b3351..b49d2bc8c 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/auth/ServerAuthSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/auth/ServerAuthSessionDataReplicatedImpl.java @@ -44,11 +44,11 @@ import java.io.Serializable; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.auth.ServerAuthSession; import org.jdiameter.common.api.app.auth.ServerAuthSessionState; import org.jdiameter.server.impl.app.auth.IServerAuthSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -65,11 +65,12 @@ public class ServerAuthSessionDataReplicatedImpl extends AppSessionDataReplicate private static final String TS_TIMERID = "TS_TIMERID"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ServerAuthSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ServerAuthSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerAuthSession.class); @@ -80,12 +81,10 @@ public ServerAuthSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsC /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ServerAuthSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -96,7 +95,7 @@ public ServerAuthSessionDataReplicatedImpl(String sessionId, MobicentsCluster mo @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); @@ -111,7 +110,7 @@ public boolean isStateless() { @Override public void setStateless(boolean stateless) { if (exists()) { - putNodeValue(STATELESS, stateless); + getNode().put(STATELESS, stateless); } else { throw new IllegalStateException(); @@ -126,7 +125,7 @@ public void setStateless(boolean stateless) { @Override public ServerAuthSessionState getServerAuthSessionState() { if (exists()) { - return (ServerAuthSessionState) getNodeValue(STATE); + return (ServerAuthSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -142,7 +141,7 @@ public ServerAuthSessionState getServerAuthSessionState() { @Override public void setServerAuthSessionState(ServerAuthSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -152,7 +151,7 @@ public void setServerAuthSessionState(ServerAuthSessionState state) { @Override public void setTsTimeout(long value) { if (exists()) { - putNodeValue(TS_TIMEOUT, value); + getNode().put(TS_TIMEOUT, value); } else { throw new IllegalStateException(); @@ -162,7 +161,7 @@ public void setTsTimeout(long value) { @Override public long getTsTimeout() { if (exists()) { - return toPrimitive((Long) getNodeValue(TS_TIMEOUT)); + return toPrimitive((Long) getNode().get(TS_TIMEOUT)); } else { throw new IllegalStateException(); @@ -172,7 +171,7 @@ public long getTsTimeout() { @Override public void setTsTimerId(Serializable value) { if (exists()) { - putNodeValue(TS_TIMERID, value); + getNode().put(TS_TIMERID, value); } else { throw new IllegalStateException(); @@ -182,7 +181,7 @@ public void setTsTimerId(Serializable value) { @Override public Serializable getTsTimerId() { if (exists()) { - return (Serializable) getNodeValue(TS_TIMERID); + return (Serializable) getNode().get(TS_TIMERID); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cca/ServerCCASessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cca/ServerCCASessionDataReplicatedImpl.java index 9ecbefc1f..d6c691fb3 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cca/ServerCCASessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cca/ServerCCASessionDataReplicatedImpl.java @@ -44,11 +44,11 @@ import java.io.Serializable; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.cca.ServerCCASession; import org.jdiameter.common.api.app.cca.ServerCCASessionState; import org.jdiameter.server.impl.app.cca.IServerCCASessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -64,11 +64,12 @@ public class ServerCCASessionDataReplicatedImpl extends AppSessionDataReplicated private static final String STATE = "STATE"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ServerCCASessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ServerCCASessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerCCASession.class); @@ -79,12 +80,10 @@ public ServerCCASessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCl /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ServerCCASessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -95,7 +94,7 @@ public ServerCCASessionDataReplicatedImpl(String sessionId, MobicentsCluster mob @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); @@ -110,7 +109,7 @@ public boolean isStateless() { @Override public void setStateless(boolean stateless) { if (exists()) { - putNodeValue(STATELESS, stateless); + getNode().put(STATELESS, stateless); } else { throw new IllegalStateException(); @@ -125,7 +124,7 @@ public void setStateless(boolean stateless) { @Override public ServerCCASessionState getServerCCASessionState() { if (exists()) { - return (ServerCCASessionState) getNodeValue(STATE); + return (ServerCCASessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -141,7 +140,7 @@ public ServerCCASessionState getServerCCASessionState() { @Override public void setServerCCASessionState(ServerCCASessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -156,7 +155,7 @@ public void setServerCCASessionState(ServerCCASessionState state) { @Override public void setTccTimerId(Serializable tccTimerId) { if (exists()) { - putNodeValue(TCCID, tccTimerId); + getNode().put(TCCID, tccTimerId); } else { throw new IllegalStateException(); @@ -171,7 +170,7 @@ public void setTccTimerId(Serializable tccTimerId) { @Override public Serializable getTccTimerId() { if (exists()) { - return (Serializable) getNodeValue(TCCID); + return (Serializable) getNode().get(TCCID); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cxdx/ServerCxDxSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cxdx/ServerCxDxSessionDataReplicatedImpl.java index db3a35979..370d1b26b 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cxdx/ServerCxDxSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/cxdx/ServerCxDxSessionDataReplicatedImpl.java @@ -42,12 +42,12 @@ package org.mobicents.diameter.impl.ha.server.cxdx; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.cxdx.ServerCxDxSession; import org.jdiameter.client.api.IContainer; import org.jdiameter.common.api.app.cxdx.CxDxSessionState; import org.jdiameter.server.impl.app.cxdx.IServerCxDxSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.cxdx.CxDxSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -59,12 +59,12 @@ public class ServerCxDxSessionDataReplicatedImpl extends CxDxSessionDataReplicatedImpl implements IServerCxDxSessionData { /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ServerCxDxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster, container); + public ServerCxDxSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); if (super.create()) { setAppSessionIface(this, ServerCxDxSession.class); @@ -75,13 +75,10 @@ public ServerCxDxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsC /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ServerCxDxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/gx/ServerGxSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/gx/ServerGxSessionDataReplicatedImpl.java index f62ec070a..7405e4060 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/gx/ServerGxSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/gx/ServerGxSessionDataReplicatedImpl.java @@ -44,11 +44,11 @@ import java.io.Serializable; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.gx.ServerGxSession; import org.jdiameter.common.api.app.gx.ServerGxSessionState; import org.jdiameter.server.impl.app.gx.IServerGxSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -64,11 +64,12 @@ public class ServerGxSessionDataReplicatedImpl extends AppSessionDataReplicatedI private static final String STATE = "STATE"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ServerGxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ServerGxSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerGxSession.class); @@ -79,12 +80,10 @@ public ServerGxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ServerGxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -95,7 +94,7 @@ public ServerGxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobi @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); @@ -110,7 +109,7 @@ public boolean isStateless() { @Override public void setStateless(boolean stateless) { if (exists()) { - putNodeValue(STATELESS, stateless); + getNode().put(STATELESS, stateless); } else { throw new IllegalStateException(); @@ -125,7 +124,7 @@ public void setStateless(boolean stateless) { @Override public ServerGxSessionState getServerGxSessionState() { if (exists()) { - return (ServerGxSessionState) getNodeValue(STATE); + return (ServerGxSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -142,7 +141,7 @@ public ServerGxSessionState getServerGxSessionState() { public void setServerGxSessionState(ServerGxSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -158,7 +157,7 @@ public void setServerGxSessionState(ServerGxSessionState state) { @Override public void setTccTimerId(Serializable tccTimerId) { if (exists()) { - putNodeValue(TCCID, tccTimerId); + getNode().put(TCCID, tccTimerId); } else { throw new IllegalStateException(); @@ -173,7 +172,7 @@ public void setTccTimerId(Serializable tccTimerId) { @Override public Serializable getTccTimerId() { if (exists()) { - return (Serializable) getNodeValue(TCCID); + return (Serializable) getNode().get(TCCID); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rf/ServerRfSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rf/ServerRfSessionDataReplicatedImpl.java index 655d575b3..18ff9f6f4 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rf/ServerRfSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rf/ServerRfSessionDataReplicatedImpl.java @@ -44,11 +44,11 @@ import java.io.Serializable; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.rf.ServerRfSession; import org.jdiameter.common.api.app.rf.ServerRfSessionState; import org.jdiameter.server.impl.app.rf.IServerRfSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -65,11 +65,12 @@ public class ServerRfSessionDataReplicatedImpl extends AppSessionDataReplicatedI private static final String TS_TIMEOUT = "TS_TIMEOUT"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ServerRfSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ServerRfSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerRfSession.class); @@ -80,12 +81,10 @@ public ServerRfSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ServerRfSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -96,7 +95,7 @@ public ServerRfSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobi @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); @@ -111,7 +110,7 @@ public boolean isStateless() { @Override public void setStateless(boolean stateless) { if (exists()) { - putNodeValue(STATELESS, stateless); + getNode().put(STATELESS, stateless); } else { throw new IllegalStateException(); @@ -126,7 +125,7 @@ public void setStateless(boolean stateless) { @Override public ServerRfSessionState getServerRfSessionState() { if (exists()) { - return (ServerRfSessionState) getNodeValue(STATE); + return (ServerRfSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -142,7 +141,7 @@ public ServerRfSessionState getServerRfSessionState() { @Override public void setServerRfSessionState(ServerRfSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -157,7 +156,7 @@ public void setServerRfSessionState(ServerRfSessionState state) { @Override public void setTsTimerId(Serializable tccTimerId) { if (exists()) { - putNodeValue(TS_TIMERID, tccTimerId); + getNode().put(TS_TIMERID, tccTimerId); } else { throw new IllegalStateException(); @@ -172,7 +171,7 @@ public void setTsTimerId(Serializable tccTimerId) { @Override public Serializable getTsTimerId() { if (exists()) { - return (Serializable) getNodeValue(TS_TIMERID); + return (Serializable) getNode().get(TS_TIMERID); } else { throw new IllegalStateException(); @@ -187,7 +186,7 @@ public Serializable getTsTimerId() { @Override public long getTsTimeout() { if (exists()) { - return toPrimitive((Long) getNodeValue(TS_TIMEOUT)); + return toPrimitive((Long) getNode().get(TS_TIMEOUT)); } else { throw new IllegalStateException(); @@ -202,7 +201,7 @@ public long getTsTimeout() { @Override public void setTsTimeout(long l) { if (exists()) { - putNodeValue(TS_TIMEOUT, l); + getNode().put(TS_TIMEOUT, l); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/ro/ServerRoSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/ro/ServerRoSessionDataReplicatedImpl.java index 0d20a7089..20217710f 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/ro/ServerRoSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/ro/ServerRoSessionDataReplicatedImpl.java @@ -44,11 +44,11 @@ import java.io.Serializable; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.ro.ServerRoSession; import org.jdiameter.common.api.app.ro.ServerRoSessionState; import org.jdiameter.server.impl.app.ro.IServerRoSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -64,11 +64,12 @@ public class ServerRoSessionDataReplicatedImpl extends AppSessionDataReplicatedI private static final String STATE = "STATE"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ServerRoSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ServerRoSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerRoSession.class); @@ -79,12 +80,10 @@ public ServerRoSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ServerRoSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -95,7 +94,7 @@ public ServerRoSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobi @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); @@ -110,7 +109,7 @@ public boolean isStateless() { @Override public void setStateless(boolean stateless) { if (exists()) { - putNodeValue(STATELESS, stateless); + getNode().put(STATELESS, stateless); } else { throw new IllegalStateException(); @@ -125,7 +124,7 @@ public void setStateless(boolean stateless) { @Override public ServerRoSessionState getServerRoSessionState() { if (exists()) { - return (ServerRoSessionState) getNodeValue(STATE); + return (ServerRoSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); @@ -141,7 +140,7 @@ public ServerRoSessionState getServerRoSessionState() { @Override public void setServerRoSessionState(ServerRoSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); @@ -156,7 +155,7 @@ public void setServerRoSessionState(ServerRoSessionState state) { @Override public void setTccTimerId(Serializable tccTimerId) { if (exists()) { - putNodeValue(TCCID, tccTimerId); + getNode().put(TCCID, tccTimerId); } else { throw new IllegalStateException(); @@ -171,7 +170,7 @@ public void setTccTimerId(Serializable tccTimerId) { @Override public Serializable getTccTimerId() { if (exists()) { - return (Serializable) getNodeValue(TCCID); + return (Serializable) getNode().get(TCCID); } else { throw new IllegalStateException(); diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rx/ServerRxSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rx/ServerRxSessionDataReplicatedImpl.java index f98d4fd21..5a2f1460d 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rx/ServerRxSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/rx/ServerRxSessionDataReplicatedImpl.java @@ -42,11 +42,11 @@ package org.mobicents.diameter.impl.ha.server.rx; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.rx.ServerRxSession; import org.jdiameter.common.api.app.rx.ServerRxSessionState; import org.jdiameter.server.impl.app.rx.IServerRxSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -61,11 +61,12 @@ public class ServerRxSessionDataReplicatedImpl extends AppSessionDataReplicatedI private static final String STATE = "STATE"; /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ServerRxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ServerRxSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerRxSession.class); @@ -76,12 +77,10 @@ public ServerRxSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ServerRxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } /* @@ -92,7 +91,7 @@ public ServerRxSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobi @Override public boolean isStateless() { if (exists()) { - return toPrimitive((Boolean) getNodeValue(STATELESS), true); + return toPrimitive((Boolean) getNode().get(STATELESS), true); } else { throw new IllegalStateException(); } @@ -106,7 +105,7 @@ public boolean isStateless() { @Override public void setStateless(boolean stateless) { if (exists()) { - putNodeValue(STATELESS, stateless); + getNode().put(STATELESS, stateless); } else { throw new IllegalStateException(); } @@ -120,7 +119,7 @@ public void setStateless(boolean stateless) { @Override public ServerRxSessionState getServerRxSessionState() { if (exists()) { - return (ServerRxSessionState) getNodeValue(STATE); + return (ServerRxSessionState) getNode().get(STATE); } else { throw new IllegalStateException(); } @@ -136,7 +135,7 @@ public ServerRxSessionState getServerRxSessionState() { public void setServerRxSessionState(ServerRxSessionState state) { if (exists()) { - putNodeValue(STATE, state); + getNode().put(STATE, state); } else { throw new IllegalStateException(); } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/s13/ServerS13SessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/s13/ServerS13SessionDataReplicatedImpl.java index df09e52e2..ce344e407 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/s13/ServerS13SessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/s13/ServerS13SessionDataReplicatedImpl.java @@ -19,12 +19,12 @@ package org.mobicents.diameter.impl.ha.server.s13; -import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.s13.ServerS13Session; import org.jdiameter.client.api.IContainer; import org.jdiameter.common.api.app.s13.S13SessionState; import org.jdiameter.server.impl.app.s13.IServerS13SessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.s13.S13SessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -36,12 +36,12 @@ public class ServerS13SessionDataReplicatedImpl extends S13SessionDataReplicatedImpl implements IServerS13SessionData { /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster - * @param container + * @param iface */ - public ServerS13SessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqnWrapper, mobicentsCluster, container); + public ServerS13SessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); if (super.create()) { setAppSessionIface(this, ServerS13Session.class); @@ -52,13 +52,10 @@ public ServerS13SessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCl /** * @param sessionId * @param mobicentsCluster - * @param container + * @param iface */ public ServerS13SessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster, container - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/sh/ShServerSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/sh/ShServerSessionDataReplicatedImpl.java index 9820dc04c..b41789c99 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/sh/ShServerSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/sh/ShServerSessionDataReplicatedImpl.java @@ -42,10 +42,10 @@ package org.mobicents.diameter.impl.ha.server.sh; - import org.restcomm.cache.FqnWrapper; +import org.jboss.cache.Fqn; import org.jdiameter.api.sh.ServerShSession; import org.jdiameter.server.impl.app.sh.IShServerSessionData; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; @@ -57,11 +57,12 @@ public class ShServerSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements IShServerSessionData { /** - * @param nodeFqnWrapper + * @param nodeFqn * @param mobicentsCluster + * @param iface */ - public ShServerSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster) { - super(nodeFqnWrapper, mobicentsCluster); + public ShServerSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster) { + super(nodeFqn, mobicentsCluster); if (super.create()) { setAppSessionIface(this, ServerShSession.class); @@ -71,12 +72,10 @@ public ShServerSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsClu /** * @param sessionId * @param mobicentsCluster + * @param iface */ public ShServerSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster) { - this( - FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), - mobicentsCluster - ); + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster); } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java new file mode 100644 index 000000000..5026b0512 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java @@ -0,0 +1,63 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.server.slg; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.jdiameter.server.impl.app.slg.IServerSLgSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slg.SLgSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ServerSLgSessionDataReplicatedImpl extends SLgSessionDataReplicatedImpl implements IServerSLgSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param container + */ + public ServerSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ServerSLgSession.class); + setSLgSessionState(SLgSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param container + */ + public ServerSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java new file mode 100644 index 000000000..122398cde --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java @@ -0,0 +1,63 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.impl.ha.server.slh; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.jdiameter.server.impl.app.slh.IServerSLhSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slh.SLhSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ServerSLhSessionDataReplicatedImpl extends SLhSessionDataReplicatedImpl implements IServerSLhSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param container + */ + public ServerSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ServerSLhSession.class); + setSLhSessionState(SLhSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param container + */ + public ServerSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/DiameterTimerTaskData.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/DiameterTimerTaskData.java index a8e9db7bf..919d748b0 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/DiameterTimerTaskData.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/DiameterTimerTaskData.java @@ -44,8 +44,8 @@ import java.io.Serializable; -import org.restcomm.timers.PeriodicScheduleStrategy; -import org.restcomm.timers.TimerTaskData; +import org.mobicents.timers.PeriodicScheduleStrategy; +import org.mobicents.timers.TimerTaskData; /** * Diameter timer task data holder. diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/ReplicatedTimerFacilityImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/ReplicatedTimerFacilityImpl.java index de577eb58..9f4a92242 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/ReplicatedTimerFacilityImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/timer/ReplicatedTimerFacilityImpl.java @@ -46,15 +46,14 @@ import org.jdiameter.api.BaseSession; import org.jdiameter.client.api.IContainer; -import org.jdiameter.client.impl.BaseSessionImpl; import org.jdiameter.common.api.data.ISessionDatasource; import org.jdiameter.common.api.timer.ITimerFacility; import org.jdiameter.common.impl.app.AppSessionImpl; -import org.restcomm.cluster.MobicentsCluster; +import org.mobicents.cluster.MobicentsCluster; import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; -import org.restcomm.timers.FaultTolerantScheduler; -import org.restcomm.timers.TimerTask; -import org.restcomm.timers.TimerTaskData; +import org.mobicents.timers.FaultTolerantScheduler; +import org.mobicents.timers.TimerTask; +import org.mobicents.timers.TimerTaskData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -111,7 +110,7 @@ public Serializable schedule(String sessionId, String timerName, long milisecond return id; } - private final class TimerTaskFactory implements org.restcomm.timers.TimerTaskFactory { + private final class TimerTaskFactory implements org.mobicents.timers.TimerTaskFactory { @Override public TimerTask newTimerTask(TimerTaskData data) { @@ -130,25 +129,13 @@ public void runTask() { try { DiameterTimerTaskData data = (DiameterTimerTaskData) getData(); BaseSession bSession = sessionDataSource.getSession(data.getSessionId()); - if (bSession == null) { + if (bSession == null || !bSession.isAppSession()) { // FIXME: error ? - logger.error("Base Session is null for sessionId: {}", data.getSessionId()); return; } else { - try { - if (!bSession.isAppSession()) { - BaseSessionImpl impl = (BaseSessionImpl) bSession; - impl.onTimer(data.getTimerName()); - } - else { - AppSessionImpl impl = (AppSessionImpl) bSession; - impl.onTimer(data.getTimerName()); - } - } - catch (Exception e) { - logger.error("Caught exception from session object!", e); - } + AppSessionImpl impl = (AppSessionImpl) bSession; + impl.onTimer(data.getTimerName()); } } catch (Exception e) { diff --git a/core/jdiameter-ha/pom.xml b/core/jdiameter-ha/pom.xml index 781fae464..93c9d2b4f 100644 --- a/core/jdiameter-ha/pom.xml +++ b/core/jdiameter-ha/pom.xml @@ -21,7 +21,8 @@ - + 1.5.9.0-build538-SNAPSHOT + 1.15.11 @@ -36,6 +37,21 @@ jdiameter-impl ${project.version} + + org.mobicents.cluster + core + ${restcomm.cluster.version} + + + org.mobicents.cluster + cache + ${restcomm.cluster.version} + + + org.mobicents.cluster + timers + ${restcomm.cluster.version} + diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java index c020f35ae..7afe1767e 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java @@ -2302,6 +2302,427 @@ public interface Avp extends Wrapper, Serializable { */ int TGPP2_MEID = 1471; + /********************************************************/ + /*** SLh interface (GMLC - HSS) AVPs (3GPP TS 29.173) ***/ + /********************************************************/ + + /** + * SLh (3GPP TS 29.173) LMSI AVP code + */ + int LMSI = 2400; + + /** + * SLh (3GPP TS 29.173) Serving-Node AVP code + */ + int SERVING_NODE = 2401; + + /** + * SLh (3GPP TS 29.173) MME-Name AVP code + */ + int MME_NAME = 2402; + + /** + * SLh (3GPP TS 29.173) MCS-Number AVP code + */ + int MSC_NUMBER = 2403; + + /** + * SLh (3GPP TS 29.173) LCS-Capabilities-Sets AVP code + */ + int LCS_CAPABILITIES_SETS = 2404; + + /** + * SLh (3GPP TS 29.173) GMLC-Address AVP code + */ + int GMLC_ADDRESS = 2405; + + /** + * SLh (3GPP TS 29.173) Additional-Serving-Node AVP code + */ + int ADDITIONAL_SERVING_NODE = 2406; + + /** + * SLh (3GPP TS 29.173) PPR-Address AVP code + */ + int PPR_ADDRESS = 2407; + + /** + * SLh (3GPP TS 29.173) MME-Realm AVP code + */ + int MME_REALM = 2408; + + /** + * SLh (3GPP TS 29.173) SGSN-Name AVP code + */ + int SGSN_NAME = 2409; + + /** + * SLh (3GPP TS 29.173) SGSN-Realm AVP code + */ + int SGSN_REALM = 2410; + + /** + * SLh (3GPP TS 29.173) RIA-Flags AVP code + */ + int RIA_FLAGS = 2411; + + /** + * SLh (3GPP TS 29.173) SGSN-Number AVP code (reused from 3GPP TS 29.272, MME - SGSN interface) + */ + int SGSN_NUMBER = 1489; + + /** + * SLh (3GPP TS 29.173) GMLC-Number AVP code (reused from 3GPP TS 29.272, MME - SGSN interface) + */ + int GMLC_NUMBER = 1474; + + /** + * SLh (3GPP TS 29.173) 3GPP-AAA-Server-Name AVP code (reused from 3GPP TS 29.273, 3GPP AAA EPS interface) + */ + int TGPP_AAA_SERVER_NAME = 318; + + // SLh re-used Diameter AVPs: + // MSISDN 3GPP TS 29.329; + // SGSN-Number 3GPP TS 29.272; + // Supported-Features 3GPP TS 29.229; + // Feature-List-ID 3GPP TS 29.229; + // Feature-List 3GPP TS 29.229; + // GMLC-Number 3GPP TS 29.272; + // 3GPP-AAA-Server-Name 3GPP TS 29.273 + + /********************************************************/ + /*** SLg interface (GMLC - MME) AVPs (3GPP TS 29.172) ***/ + /*** Diameter ELP Application (EPC LCS Protocol) ***/ + /********************************************************/ + + /** + * SLg (3GPP TS 29.172) SLg-Location-Type AVP code + */ + int SLG_LOCATION_TYPE = 2500; + + /** + * SLg (3GPP TS 29.172) LCS-EPS-Client-Name AVP code + */ + int LCS_EPS_CLIENT_NAME = 2501; + + /** + * SLg (3GPP TS 29.172) LCS_Requestor_Name AVP code + */ + int LCS_REQUESTOR_NAME = 2502; + + /** + * SLg (3GPP TS 29.172) LCS-Priority AVP code + */ + int LCS_PRIORITY = 2503; + + /** + * SLg (3GPP TS 29.172) LCS-QoS AVP code + */ + int LCS_QOS = 2504; + + /** + * SLg (3GPP TS 29.172) Horizontal-Accuracy AVP code + */ + int HORIZONTAL_ACCURACY = 2505; + + /** + * SLg (3GPP TS 29.172) Vertical-Accuracy AVP code + */ + int VERTICAL_ACCURACY = 2506; + + /** + * SLg (3GPP TS 29.172) Vertical-Requested AVP code + */ + int VERTICAL_REQUESTED = 2507; + + /** + * SLg (3GPP TS 29.172) Velocity-Requested AVP code + */ + int VELOCITY_REQUESTED = 2508; + + /** + * SLg (3GPP TS 29.172) Response-Time AVP code + */ + int RESPONSE_TIME = 2509; + + /** + * SLg (3GPP TS 29.172) Supported-GAD-Shapes AVP code + */ + int SUPPORTED_GAD_SHAPES = 2510; + + /** + * SLg (3GPP TS 29.172) LCS-Codeword AVP code + */ + int LCS_CODEWORD = 2511; + + /** + * SLg (3GPP TS 29.172) LCS-Privacy-Check AVP code + */ + int LCS_PRIVACY_CHECK = 2512; + + /** + * SLg (3GPP TS 29.172) Accuracy-Fulfilment-Indicator AVP code + */ + int ACCURACY_FULFILMENT_INDICATOR = 2513; + + /** + * SLg (3GPP TS 29.172) Age-Of-Location-Estimate AVP code + */ + int AGE_OF_LOCATION_ESTIMATE = 2514; + + /** + * SLg (3GPP TS 29.172) Velocity-Estimate 2515 AVP code + */ + int VELOCITY_ESTIMATE = 2515; + + /** + * SLg (3GPP TS 29.172) EUTRAN-Positioning-Data AVP code + */ + int EUTRAN_POSITIONING_DATA = 2516; + + /** + * SLg (3GPP TS 29.172) ECGI AVP code + */ + int ECGI = 2517; + + /** + * SLg (3GPP TS 29.172) Location_Event AVP code + */ + int LOCATION_EVENT = 2518; + + /** + * SLg (3GPP TS 29.172) Pseudonym-Indicator + */ + int PSEUDONYM_INDICATOR = 2519; + + /** + * SLg (3GPP TS 29.172) LCS-Service-Type-ID AVP Code + */ + int LCS_SERVICE_TYPE_ID = 2520; + + /** + * SLg (3GPP TS 29.172) LCS-Privacy-Check-Non-Session AVP Code + */ + int LCS_PRIVACY_CHECK_NON_SESSION = 2521; + + /** + * SLg (3GPP TS 29.172) LCS-Privacy-Check-Session AVP Code + */ + int LCS_PRIVACY_CHECK_SESSION = 2522; + + /** + * SLg (3GPP TS 29.172) LCS-QoS-Class AVP Code + */ + int LCS_QOS_CLASS = 2523; + + /** + * SLg (3GPP TS 29.172) GERAN-Positioning-Info AVP Code + */ + int GERAN_POSITIONING_INFO = 2524; + + /** + * SLg (3GPP TS 29.172) GERAN-Positioning-Data AVP Code + */ + int GERAN_POSITIONING_DATA = 2525; + + /** + * SLg (3GPP TS 29.172) GERAN-GANSS-Positioning-Data AVP Code + */ + int GERAN_GANSS_POSITIONING_DATA = 2526; + + /** + * SLg (3GPP TS 29.172) UTRAN-Positioning-Info AVP Code + */ + int UTRAN_POSITIONING_INFO = 2527; + + /** + * SLg (3GPP TS 29.172) UTRAN-Positioning-Data AVP Code + */ + int UTRAN_POSITIONING_DATA = 2528; + + /** + * SLg (3GPP TS 29.172) UTRAN-GANSS-Positioning-Data AVP Code + */ + int UTRAN_GANSS_POSITIONING_DATA = 2529; + + /** + * SLg (3GPP TS 29.172) LRR-Flags AVP Code + */ + int LRR_FLAGS = 2530; + + /** + * SLg (3GPP TS 29.172) LCS-Reference-Number AVP Code + */ + int LCS_REFERENCE_NUMBER = 2531; + + /** + * SLg (3GPP TS 29.172) Deferred-Location-Type AVP Code + */ + int DEFERRED_LOCATION_TYPE = 2532; + + /** + * SLg (3GPP TS 29.172) Area-Event-Info AVP Code + */ + int AREA_EVENT_INFO = 2533; + + /** + * SLg (3GPP TS 29.172) Area-Definition AVP Code + */ + int AREA_DEFINITION = 2534; + + /** + * SLg (3GPP TS 29.172) Area AVP Code + */ + int AREA = 2535; + + /** + * SLg (3GPP TS 29.172) Area-Type AVP Code + */ + int AREA_TYPE = 2536; + + /** + * SLg (3GPP TS 29.172) Area-Identification AVP Code + */ + int AREA_IDENTIFICATION = 2537; + + /** + * SLg (3GPP TS 29.172) Occurrence-Info AVP Code + */ + int OCCURRENCE_INFO = 2538; + + /** + * SLg (3GPP TS 29.172) Interval-Time AVP Code + */ + int INTERVAL_TIME = 2539; + + /** + * SLg (3GPP TS 29.172) Periodic-LDR-Information AVP Code + */ + int PERIODIC_LDR_INFORMATION = 2540; + + /** + * SLg (3GPP TS 29.172) Reporting-Amount AVP Code + */ + int REPORTING_AMOUNT = 2541; + + /** + * SLg (3GPP TS 29.172) Reporting-Interval AVP Code + */ + int REPORTING_INTERVAL = 2542; + + /** + * SLg (3GPP TS 29.172) Reporting-PLMN-List AVP Code + */ + int REPORTING_PLMN_LIST = 2543; + + /** + * SLg (3GPP TS 29.172) PLMN-ID-List AVP Code + */ + int PLMN_ID_LIST = 2544; + + /** + * SLg (3GPP TS 29.172) PLR-Flags AVP Code + */ + int PLR_FLAGS = 2545; + + /** + * SLg (3GPP TS 29.172) PLA-Flags AVP Code + */ + int PLA_FLAGS = 2546; + + /** + * SLg (3GPP TS 29.172) Deferred-MT-LR-Data AVP Code + */ + int DEFERRED_MT_LR_DATA = 2547; + + /** + * SLg (3GPP TS 29.172) Termination-Cause AVP Code; + */ + int TERMINATION_CAUSE_LCS = 2548; + + /** + * SLg (3GPP TS 29.172) LRA-Flags AVP Code + */ + int LRA_FLAGS = 2549; + + /** + * SLg (3GPP TS 29.172) Periodic-Location-Support-Indicator AVP Code + */ + int PERIODIC_LOCATION_SUPPORT_INDICATOR = 2550; + + /** + * SLg (3GPP TS 29.172) + */ + int PRIORITIZED_LIST_INDICATOR = 2551; + + /** + * SLg (3GPP TS 29.172)ESMLC-Cell-Info AVP Code + */ + int ESMLC_CELL_INFO = 2552; + + /** + * SLg (3GPP TS 29.172) Cell-Portion-ID AVP Code + */ + int CELL_PORTION_ID = 2553; + + /** + * SLg (3GPP TS 29.172) 1xRTT-RCID AVP Code + */ + int ONEXRTT_RCID = 2554; + + /** + * SLg (3GPP TS 29.172) Civic-Address AVP Code + */ + int CIVIC_ADDRESS = 2556; + + /** + * SLg (3GPP TS 29.172) Barometric-Pressure AVP Code + */ + int BAROMETRIC_PRESSURE = 2557; + + /** + * SLg (3GPP TS 29.172) UTRAN-Additional-Positioning-Data AVP Code + */ + int UTRAN_ADDITIONAL_POSITIONING_DATA = 2558; + + /** + * SLg (3GPP TS 29.172) Service-Selection AVP Code (reused from 3GPP TS 29.272 & IETF RFC 5778) + */ + int SERVICE_SELECTION = 493; + + /** + * SLg (3GPP TS 29.172) Cell-Global-Identity AVP Code (reused from 3GPP TS 29.272) + */ + int CELL_GLOBAL_IDENTITY = 1604; + + /** + * SLg (3GPP TS 29.172) Visited-PLMN-Id AVP Code (reused from 3GPP TS 29.272) + */ + int VISITED_PLMN_ID = 1407; + + /** + * SLg (3GPP TS 29.172) Service-Area-Identity AVP Code (reused from 3GPP TS 29.272) + */ + int SERVICE_AREA_IDENTITY = 1607; + + // Diameter ELP Application (SLg) reused AVPs: + // LCS-Format-Indicator 1237 3GPP TS 32.299; + // LCS-Name-String 1238 3GPP TS 2.299; + // LCS-Client-Type 1241 3GPP TS 32.299 + // LCS-Requestor-Id-String 1240 3GPP TS 32.299; + // Location-Estimate 1242 3GPP TS 32.299; + // IMEI 1402 3GPP TS 29.272; + // MSISDN 701 3GPP TS 29.329; + // Service-Selection 493 3GPP TS 29.272, IETF RFC 5778 + // User-Name 1 IETF RFC 3588; + // Supported-Features 628 3GPP TS 29.229; + // Feature-List-ID 629 3GPP TS 29.229; + // Feature-List 630 3GPP TS 29.229; + // Serving-Node 2401 3GPP TS 29.173; + // Cell-Global-Identity 1604 3GPP TS 29.272; + // Service-Area-Identity 1607 3GPP TS 29.272; + // GMLC-Address 2405 3GPP TS 29.173; + // Visited-PLMN-Id 1407 3GPP TS 29.272 /** * @return the AVP code. diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/AvpSet.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/AvpSet.java index 44b5a3570..a2af490a8 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/AvpSet.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/AvpSet.java @@ -53,8 +53,6 @@ * Serializable interface allows use this class in SLEE Event objects * * @author erick.svenson@yahoo.com - * @author Grzegorz Figiel [ProIDS] - * * @version 1.5.1 Final */ public interface AvpSet extends Iterable, Serializable, Wrapper { @@ -96,21 +94,6 @@ public interface AvpSet extends Iterable, Serializable, Wrapper { */ AvpSet getAvps(int avpCode, long vendorId); - /** - * Get position of the first instance of the AVP - * @param avpCode code of the Avp - * @return index (position) of the first occurrence of the Avp. -1 in case Avp is not found - */ - int getAvpIndex(int avpCode); - - /** - * Get position of the first instance of the AVP - * @param avpCode code of the Avp - * @param vendorId vendorId of the Avp - * @return index (position) of the first occurrence of the Avp. -1 in case Avp is not found - */ - int getAvpIndex(int avpCode, long vendorId); - /** * Remove AVPs with avpCode * @param avpCode code of Avp diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/BaseSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/BaseSession.java index 572222746..e724e7b07 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/BaseSession.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/BaseSession.java @@ -104,6 +104,4 @@ public interface BaseSession { * @return session-id as String (Session-Id AVP) */ String getSessionId(); - - String IDLE_SESSION_TIMER_NAME = "IDLE_SESSION_TIMER"; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSession.java new file mode 100644 index 000000000..4c90edea2 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSession.java @@ -0,0 +1,85 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slg; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateMachine; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.ProvideLocationRequest; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ClientSLgSession extends AppSession, StateMachine { + + /** + * Send Provide-Location-Request to server + * + * @param request Provide-Location-Request event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendProvideLocationRequest(ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + /** + * Send Location-Report-Request to server + * + * @param request Location-Report-Request event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendLocationReportRequest(LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSessionListener.java new file mode 100644 index 000000000..b9a04760c --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSessionListener.java @@ -0,0 +1,73 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slg; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ClientSLgSessionListener { + + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocationRequest request, ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSession.java new file mode 100644 index 000000000..d24bad197 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSession.java @@ -0,0 +1,85 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slg; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateMachine; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ServerSLgSession extends AppSession, StateMachine { + + /** + * Send Provide-Location-Answer to client + * + * @param answer Provide-Location-Answer event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendProvideLocationAnswer(ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + /** + * Send Location-Report-Answer to client + * + * @param answer Location-Report-Answer event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendLocationReportAnswer(LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSessionListener.java new file mode 100644 index 000000000..261dbe7a4 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSessionListener.java @@ -0,0 +1,70 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slg; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.ProvideLocationRequest; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ServerSLgSessionListener { + + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java new file mode 100644 index 000000000..89d1c8039 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java @@ -0,0 +1,70 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jdiameter.api.slg.events; + +import org.jdiameter.api.app.AppAnswerEvent; + +/** + * @author Fernando Mendioroz + * + */ + +/* + * As for 3GPP TS 29.172 v13.0.0, Subscriber Location Report operation is used by an MME or SGSN to provide the location of a + * target UE to a GMLC, when a request for location has been implicitly issued or when a Delayed Location Reporting is triggered + * after receipt of a request for location for a UE transiently not reachable. + * + * The Location-Report-Answer (LRA) command, indicated by the Command-Code field set to 8388621 and the "R" bit cleared in the + * Command Flags field, is sent by the GMLC to the MME or SGSN in response to the Location-Report-Request command (Subscriber + * Location Report operation answer) + */ + +public interface LocationReportAnswer extends AppAnswerEvent{ + + String _SHORT_NAME = "LRA"; + String _LONG_NAME = "Location-Report-Answer"; + + int code = 8388621; + + boolean isGMLCAddressAvpPresent(); + java.net.InetAddress getGMLCAddress(); + + boolean isLRAFlagsAvpPresent(); + long getLRAFLags(); + + boolean isReportingPLMNListAvpPresent(); + // Reporting-PLMN-List AVP of type grouped, includes: + // PLMN-ID-List, Prioritized-List-Indicator + boolean isPrioritizedListIndicatorAvpPresent(); + int getPrioritizedListIndicator(); + boolean isPLMNIDListAvpPresent(); + // PLMN-ID-List AVP of type grouped, includes: + // Visited-PLMN-Id, Periodic-Location-Support-Indicator + boolean isVisitedPLMNIdAvpPresent(); + byte[] getVisitedPLMNId(); + boolean isPeriodicLocationSupportIndicatorAvpPresent(); + int getPeriodicLocationSupportIndicator(); + + boolean isLCSReferenceNumberAvpPresent(); + byte[] getLCSReferenceNumber(); + +} \ No newline at end of file diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportRequest.java new file mode 100644 index 000000000..294e76962 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportRequest.java @@ -0,0 +1,192 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jdiameter.api.slg.events; + +import org.jdiameter.api.app.AppRequestEvent; + +/** + * @author Fernando Mendioroz + * + */ + +/* + * As for 3GPP TS 29.172 v13.0.0, Subscriber Location Report operation is used by an MME or SGSN to provide the location of a + * target UE to a GMLC, when a request for location has been implicitly issued or when a Delayed Location Reporting is triggered + * after receipt of a request for location for a UE transiently not reachable. + * + * The Location-Report-Request (LRR) command, indicated by the Command-Code field set to 8388621 and the "R" bit set in the + * Command Flags field, is sent by the MME or SGSN in order to provide subscriber location data to the GMLC (Subscriber Location + * Report operation request) + */ + +public interface LocationReportRequest extends AppRequestEvent { + + String _SHORT_NAME = "LRR"; + String _LONG_NAME = "Location-Report-Request"; + + int code = 8388621; + + boolean isLocationEventAvpPresent(); + int getLocationEvent(); + + boolean isUserNameAvpPresent(); // Mapped IE: IMSI + String getUserName(); // Mapped IE: IMSI + + boolean isMSISDNAvpPresent(); + byte[] getMSISDN(); + + boolean isIMEIAvpPresent(); + String getIMEI(); + + boolean isLCSEPSClientNameAvpPresent(); + // LCS-EPS-Client-Name AVP of type grouped, includes: + // LCS-Name-String, LCS-Format-Indicator + boolean isLSCNameStringAvpPresent(); + String getLSCNameString(); + boolean isLCSFormatIndicatorAvpPresent(); + int getLCSFormatIndicator(); + + boolean isLocationEstimateAvpPresent(); + byte[] getLocationEstimate(); + + boolean isAccuracyFulfilmentIndicatorAvpPresent(); + int getAccuracyFulfilmentIndicator(); + + boolean isAgeOfLocationEstimateAvpPresent(); + long getAgeOfLocationEstimate(); + + boolean isVelocityEstimateAvpPresent(); + byte[] getVelocityEstimate(); + + boolean isEUTRANPositioningDataAvpPresent(); + byte[] getEUTRANPositioningData(); + + boolean isECGIAvpPresent(); + byte[] getECGI(); + + boolean isGERANPositioningInfoAvpPresent(); + // GERAN-Positioning-Info AVP of type grouped, includes: + // GERAN-Positioning-Data, GERAN-GANSS-Positioning-Data + boolean isGERANPositioningDataAvpPresent(); + byte[] getGERANPositioningData(); + boolean isGERANGANSSPositioningDataAvpPresent(); + byte[] getGERANGANSSPositioningData(); + + boolean isCellGlobalIdentityAvpPresent(); + byte[] getCellGlobalIdentity(); + + boolean isUTRANPositioningInfoAvpPresent(); + // UTRAN-Positioning-Info AVP of type grouped, includes: + // UTRAN-Positioning-Data, UTRAN-GANSS-Positioning-Data + boolean isUTRANPositioningDataAvpPresent(); + byte[] getUTRANPositioningData(); + boolean isUTRANGANSSPositioningDataAvpPresent(); + byte[] getUTRANGANSSPositioningData(); + + boolean isServiceAreaIdentityAvpPresent(); + byte[] getServiceAreaIdentity(); + + boolean isLCSServiceTypeIDAvpPresent(); + long getLCSServiceTypeID(); + + boolean isPseudonymIndicatorAvpPresent(); + int getPseudonymIndicator(); + + boolean isLCSQoSAvpPresent(); + // LCS-QoS AVP of type grouped, includes: + // LCS-QoS-Class, Horizontal-Accuracy, Vertical-Accuracy + // Vertical-Requested, Response-Time + boolean isLCSQoSClassAvpPresent(); + int getLCSQoSClass(); + boolean isHorizontalAccuracyAvpPresent(); + long getHorizontalAccuracy(); + boolean isVerticalAccuracyAvpPresent(); + long getVerticalAccuracy(); + boolean isVerticalRequestedAvpPresent(); + int getVerticalRequested(); + boolean isResponseTimeAvpPresent(); + int getResponseTime(); + + boolean isServingNodeAvpPresent(); + // [ Serving-Node ] IE: Target Serving Node Identity + // Serving-Node AVP of type grouped, includes: + // SGSN-Number, SGSN-Name, SGSN-Realm. + // MME-Name, MME-Realm + // MSC-Number + // 3GPP-AAA-Server-Name, LCS-Capabilities-Sets, GMLC-Address + boolean isSGSNNumberAvpPresent(); + byte[] getSGSNNumber(); + boolean isSGSNNameAvpPresent(); + String getSGSNName(); + boolean isSGSNRealmAvpPresent(); + String getSGSNRealm(); + boolean isMMENameAvpPresent(); + String getMMEName(); + boolean isMMERealmAvpPresent(); + String getMMERealm(); + boolean isMSCNumberAvpPresent(); + byte[] getMSCNumber(); + boolean is3GPPAAAServerNameAvpPresent(); + String get3GPPAAAServerName(); + boolean isLCSCapabilitiesSetsAvpPresent(); + long getLCSCapabilitiesSets(); + boolean isGMLCAddressAvpPresent(); + java.net.InetAddress getGMLCAddress(); + + boolean isLRRFlagsAvpPresent(); + long getLRRFLags(); + + boolean isLCSReferenceNumberAvpPresent(); + byte[] getLCSReferenceNumber(); + + boolean isDeferredMTLRDataAvpPresent(); + // Deferred-MT-LR-Data AVP of type grouped, includes: + // Deferred-Location-Type, Termination-Cause. + boolean isDeferredLocationTypeAvpPresent(); + long getDeferredLocationType(); + boolean isTerminationCauseAvpPresent(); + long getTerminationCause(); + + boolean isHGMLCAddressAvpPresent(); // IE: H-GMLC Address mapped to GMLC-Address AVP + java.net.InetAddress getHGMLCAddress(); + + boolean isPeriodicLDRInfoAvpPresent(); + // Periodic-LDR-Info AVP of type grouped, includes: + // Reporting-Amount, Reporting-Interval + boolean isReportingAmountAvpPresent(); + long getReportingAmount(); + boolean isReportingIntervalAvpPresent(); + long getReportingInterval(); + + boolean isESMLCCellInfoAvpPresent(); + long getCellPortionId(); + + boolean is1xRTTRCIDAvpPresent(); + byte[] get1xRTTRCID(); + + boolean isCivicAddressAvpPresent(); + String getCivicAddress(); + + boolean isBarometricPressureAvpPresent(); + long getBarometricPressure(); + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java new file mode 100644 index 000000000..39590a03e --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java @@ -0,0 +1,129 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jdiameter.api.slg.events; + +import org.jdiameter.api.app.AppAnswerEvent; + +/** + * @author Fernando Mendioroz + * + */ + +/* + * As for 3GPP TS 29.172 v13.0.0, the Provide Subscriber Location operation is used by a GMLC to request the location of a + * target UE from the MME or SGSN at any time, as part of EPC-MT-LR (Evolved Packet Core Mobile Terminated Location Request) or + * PS-MT-LR (Packet Switched Mobile Terminated Location Request) positioning procedures. The response contains a location + * estimate of the target UE and other additional information. This operation is also used by a GMLC to request the location of + * the target UE from the SGSN at any time, as part of deferred MT-LR procedure. The response contains the acknowledgment of the + * receipt of the request and other additional information. + * + * The Provide-Location-Answer (PLA) command, indicated by the Command-Code field set to 8388620 and the "R" bit cleared in the + * Command Flags field, is sent by the MME or SGSN to the GMLC in response to the Provide-Location-Request command (Provide + * Subscriber Location operation answer) + */ + +public interface ProvideLocationAnswer extends AppAnswerEvent{ + + String _SHORT_NAME = "PLA"; + String _LONG_NAME = "Provide-Location-Answer"; + + int code = 8388620; + + boolean isLocationEstimateAvpPresent(); + byte[] getLocationEstimate(); + + boolean isAccuracyFulfilmentIndicatorAvpPresent(); + int getAccuracyFulfilmentIndicator(); + + boolean isAgeOfLocationEstimateAvpPresent(); + long getAgeOfLocationEstimate(); + + boolean isVelocityEstimateAvpPresent(); + byte[] getVelocityEstimate(); + + boolean isEUTRANPositioningDataAvpPresent(); + byte[] getEUTRANPositioningData(); + + boolean isECGIAvpPresent(); + byte[] getECGI(); + + boolean isGERANPositioningInfoAvpPresent(); + // GERAN-Positioning-Info AVP of type grouped, includes: + // GERAN-Positioning-Data, GERAN-GANSS-Positioning-Data + boolean isGERANPositioningDataAVPPresent(); + byte[] getGERANPositioningData(); + boolean isGERANGANSSPositioningDataAVPPresent(); + byte[] getGERANGANSSPositioningData(); + + boolean isCellGlobalIdentityAvpPresent(); + byte[] getCellGlobalIdentity(); + + boolean isUTRANPositioningInfoAvpPresent(); + // UTRAN-Positioning-Info AVP of type grouped, includes: + // UTRAN-Positioning-Data, UTRAN-GANSS-Positioning-Data + boolean isUTRANPositioningDataAVPPresent(); + byte[] getUTRANPositioningData(); + boolean isUTRANGANSSPositioningDataAVPPresent(); + byte[] getUTRANGANSSPositioningData(); + + boolean isServiceAreaIdentityAvpPresent(); + byte[] getServiceAreaIdentity(); + + boolean isServingNodeAvpPresent(); + // [ Serving-Node ] IE: Target Serving Node Identity + // Serving-Node AVP of type grouped, includes: + // SGSN-Number, SGSN-Name, SGSN-Realm. + // MME-Name, MME-Realm + // MSC-Number + // 3GPP-AAA-Server-Name, LCS-Capabilities-Sets, GMLC-Address + boolean isSGSNNumberAvpPresent(); + byte[] getSGSNNumber(); + boolean isSGSNNameAvpPresent(); + String getSGSNName(); + boolean isSGSNRealmAvpPresent(); + String getSGSNRealm(); + boolean isMMENameAvpPresent(); + String getMMEName(); + boolean isMMERealmAvpPresent(); + String getMMERealm(); + boolean isMSCNumberAvpPresent(); + byte[] getMSCNumber(); + boolean is3GPPAAAServerNameAvpPResent(); + String get3GPPAAAServerName(); + boolean isLCSCapabilitiesSetsAvpPresent(); + long getLCSCapabilitiesSets(); + boolean isGMLCAddressAvpPresent(); + java.net.InetAddress getGMLCAddress(); + + boolean isPLAFlagsAvpPresent(); + long getPLAFlags(); + + boolean isESMLCCellInfoAvpPresent(); + long getCellPortionId(); + + boolean isCivicAddressAvpPresent(); + String getCivicAddress(); + + boolean isBarometricPressureAvpPresent(); + long getBarometricPressure(); + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationRequest.java new file mode 100644 index 000000000..29e165a44 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationRequest.java @@ -0,0 +1,174 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jdiameter.api.slg.events; + +import org.jdiameter.api.app.AppRequestEvent; + +/** + * @author Fernando Mendioroz + * + */ + +/* + * As for 3GPP TS 29.172 v13.0.0, the Provide Subscriber Location operation is used by a GMLC to request the location of a + * target UE from the MME or SGSN at any time, as part of EPC-MT-LR (Evolved Packet Core Mobile Terminated Location Request) or + * PS-MT-LR (Packet Switched Mobile Terminated Location Request) positioning procedures. The response contains a location + * estimate of the target UE and other additional information. This operation is also used by a GMLC to request the location of + * the target UE from the SGSN at any time, as part of deferred MT-LR procedure. The response contains the acknowledgment of the + * receipt of the request and other additional information. + * + * The Provide-Location-Request (PLR) command, indicated by the Command-Code field set to 8388620 and the "R" bit set in the + * Command Flags field, is sent by the GMLC in order to request subscriber location to the MME or SGSN (Provide Subscriber + * Location operation request) + */ + +public interface ProvideLocationRequest extends AppRequestEvent { + + String _SHORT_NAME = "PLR"; + String _LONG_NAME = "Provide-Location-Request"; + + int code = 8388620; + + boolean isSLgLocationTypeAvpPresent(); + int getSLgLocationType(); + + boolean isUserNameAvpPresent(); // Mapped IE: IMSI + String getUserName(); // Mapped IE: IMSI + + boolean isMSISDNAvpPresent(); + byte[] getMSISDN(); + + boolean isIMEIAvpPresent(); + String getIMEI(); + + boolean isLCSEPSClientNameAvpPresent(); + // LCS-EPS-Client-Name AVP of type grouped, includes: + // LCS-Name-String, LCS-Format-Indicator + boolean isLSCNameStringAvpPresent(); + String getLSCNameString(); + boolean isLCSFormatIndicatorAvpPresent(); + int getLCSFormatIndicator(); + + boolean isLCSCLientTypeAvpPresent(); + int getLCSClientType(); + + boolean isLCSRequestorNamePresent(); + // LCS-Requestor-NAme AVP of type grouped, includes: + // LCS-Requestor-Id-String, LCS-Format-Indicator + boolean isLCSRequestorIdStringAvpPresent(); + String getLCSRequestorIdString(); + boolean isReqLCSFormatIndicatorAvpPresent(); + int getReqLCSFormatIndicator(); + + boolean isLCSPriorityPresent(); + long getLCSPriority(); + + boolean isLCSQoSAvpPresent(); + // LCS-QoS AVP of type grouped, includes: + // LCS-QoS-Class, Horizontal-Accuracy, Vertical-Accuracy + // Vertical-Requested, Response-Time + boolean isLCSQoSClassAvpPresent(); + int getLCSQoSClass(); + boolean isHorizontalAccuracyAvpPresent(); + long getHorizontalAccuracy(); + boolean isVerticalAccuracyAvpPresent(); + long getVerticalAccuracy(); + boolean isVerticalRequestedAvpPresent(); + int getVerticalRequested(); + boolean isResponseTimeAvpPresent(); + int getResponseTime(); + + boolean isVelocityRequestedAvpPresent(); + int getVelocityRequested(); + + boolean isSupportedGADShapesAvpPresent(); + long getSupportedGADSahpes(); + + boolean isLSCServiceTypeIdAvpPresent(); + long getLSCServiceTypeId(); + + boolean isLCSCodewordAvpPresent(); + String getLCSCodeword(); + + boolean isServiceSelectionAvpPresent(); + String getServiceSelection(); // IE: APN + + boolean isLCSPrivacyCheckSessionAvpPresent(); // IE: Session-Related Privacy Check + // LCS-Privacy-Check-Session of type grouped, includes + // LCS-Privacy-Check + boolean isLCSPrivacyCheckAvpPresent(); + int getLCSPrivacyCheck(); + + boolean isLCSPrivacyCheckNonSessionAvpPresent(); // IE: Non-Session-Related Privacy Check + // LCS-Privacy-Check-Non-Session of type grouped, includes + // LCS-Privacy-Check + boolean isLCSPrivacyCheckNSAvpPresent(); + int getLCSPrivacyCheckNS(); + + boolean isDeferredLocationTypeAvpPresent(); + long getDeferredLocationType(); + + boolean isLCSReferenceNumberAvpPresent(); + byte[] getLCSReferenceNumber(); + + boolean isAreaEventInfoAvpPresent(); + // Area-Event-Info AVP of type grouped, includes: + // Area-Definition, Occurrence-Info, Interval-Time + boolean isOccurrenceInfoAvpPresent(); + int getOccurrenceInfo(); + boolean isIntervalTimeAvpPresent(); + long getIntervalTime(); + boolean isAreaDefinitionAvpPresent(); + // Area-Definition AVP of type grouped, includes: + // Area-Type, Area-Identification + boolean isAreaTypeAvpPresent(); + long getAreaType(); + boolean isAreaIdentificationAvpPresent(); + byte[] getAreaIdentification(); + + boolean isGMLCAddressAvpPresent(); + java.net.InetAddress getGMLCAddress(); + + boolean isPLRFlagsAvpPresent(); + long getPLRFLags(); + + boolean isPeriodicLDRInfoAvpPresent(); + // Periodic-LDR-Info AVP of type grouped, includes: + // Reporting-Amount, Reporting-Interval + boolean isReportingAmountAvpPresent(); + long getReportingAmount(); + boolean isReportingIntervalAvpPresent(); + long getReportingInterval(); + + boolean isReportingPLMNListAvpPresent(); + // Reporting-PLMN-List AVP of type grouped, includes: + // PLMN-ID-List, Prioritized-List-Indicator + boolean isPrioritizedListIndicatorAvpPresent(); + int getPrioritizedListIndicator(); + boolean isPLMNIDListAvpPresent(); + // PLMN-ID-List AVP of type grouped, includes: + // Visited-PLMN-Id, Periodic-Location-Support-Indicator + boolean isVisitedPLMNIdAvpPresent(); + byte[] getVisitedPLMNId(); + boolean isPeriodicLocationSupportIndicatorAvpPresent(); + int getPeriodicLocationSupportIndicator(); +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSession.java new file mode 100644 index 000000000..90e2095ae --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSession.java @@ -0,0 +1,73 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slh; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateMachine; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ClientSLhSession extends AppSession, StateMachine { + + /** + * Send LCS-Routing-Info-Request to server + * + * @param request LCS-Routing-Info-Request event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + + void sendLCSRoutingInfoRequest(LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSessionListener.java new file mode 100644 index 000000000..a80e4dccf --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSessionListener.java @@ -0,0 +1,69 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slh; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; + + +/** + * @author Fernando Mendioroz + * + */ + +public interface ClientSLhSessionListener { + + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + void doLCSRoutingInfoAnswerEvent(ClientSLhSession session, LCSRoutingInfoRequest request, LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSession.java new file mode 100644 index 000000000..2d7904cf3 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSession.java @@ -0,0 +1,72 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slh; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateMachine; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ServerSLhSession extends AppSession, StateMachine { + + /** + * Send LCS-Routing-Info-Answer to client + * + * @param answer LCS-Routing-Info-Answer event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendLCSRoutingInfoAnswer(LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSessionListener.java new file mode 100644 index 000000000..c0e2fcd0c --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSessionListener.java @@ -0,0 +1,67 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.api.slh; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ServerSLhSessionListener { + + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + + void doLCSRoutingInfoRequestEvent(ServerSLhSession session, LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoAnswer.java new file mode 100644 index 000000000..a6734e135 --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoAnswer.java @@ -0,0 +1,132 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jdiameter.api.slh.events; + +import org.jdiameter.api.app.AppAnswerEvent; + +/** + * @author Fernando Mendioroz + * + */ + +/* + * As for 3GPP TS 29.173 v13.0.0, the LCS-Routing-Info-Answer (RIA) command, indicated by the Command-Code field set to 8388622 + * and the "R" bit cleared in the Command Flags field, is sent from HSS to GMLC. The procedure invoked by the GMLC is used for + * retrieving routing information for LCS (Location Services) for a specified user from the HSS via a LCS-Routing-Info-Request + * (RIR) command. + * + */ +public interface LCSRoutingInfoAnswer extends AppAnswerEvent { + + String _SHORT_NAME = "RIA"; + String _LONG_NAME = "LCS-Routing-Info-Answer"; + + int code = 8388622; + + boolean isUserNameAVPPresent(); // Mapped IE: IMSI + String getUserName(); // Mapped IE: IMSI + + boolean isMSISDNAVPPresent(); + byte[] getMSISDN(); + + boolean isLMSIAVPPresent(); + byte[] getLMSI(); + + boolean isServingNodeAVPPresent(); + // Serving-Node AVP of type grouped, includes: + // SGSN-Number, SGSN-Name, SGSN-Realm + // MME-Name, MME-Realm + // MSC-Number + // 3GPP-AAA-Server-Name + // LCS-Capabilities-Sets + // GMLC-Address + + boolean isSGSNNumberAVPPresent(); + byte[] getSGSNNumber(); + + boolean isSGSNNameAVPPresent(); + String getSGSNName(); + + boolean isSGSNRealmAVPPresent(); + String getSGSNRealm(); + + boolean isMMENameAVPPresent(); + String getMMEName(); + + boolean isMMERealmAVPPresent(); + String getMMERealm(); + + boolean isMSCNumberAVPPresent(); + byte[] getMSCNumber(); + + boolean is3GPPAAAServerNameAVPPresent(); + String get3GPPAAAServerName(); + + boolean isLCSCapabilitiesSetsAVPPresent(); + long getLCSCapabilitiesSets(); + + boolean isGMLCAddressAVPPresent(); + java.net.InetAddress getGMLCAddress(); + + boolean isAdditionalServingNodeAVPPresent(); + // Serving-Node AVP of type grouped, includes: + // SGSN-Number, SGSN-Name, SGSN-Realm + // MME-Name, MME-Realm + // MSC-Number + // 3GPP-AAA-Server-Name + // LCS-Capabilities-Sets + // GMLC-Address + + boolean isAdditionalSGSNNumberAVPPresent(); + byte[] getAdditionalSGSNNumber(); + + boolean isAdditionalSGSNNameAVPPresent(); + String getAdditionalSGSNName(); + + boolean isAdditionalSGSNRealmAVPPresent(); + String getAdditionalSGSNRealm(); + + boolean isAdditionalMMENameAVPPresent(); + String getAdditionalMMEName(); + + boolean isAdditionalMMERealmAVPPresent(); + String getAdditionalMMERealm(); + + boolean isAdditionalMSCNumberAVPPresent(); + byte[] getAdditionalMSCNumber(); + + boolean isAdditional3GPPAAAServerNameAVPPresent(); + String getAdditional3GPPAAAServerName(); + + boolean isAdditionalLCSCapabilitiesSetsAVPPresent(); + long getAdditionalLCSCapabilitiesSets(); + + boolean isAdditionalGMLCAddressAVPPresent(); + java.net.InetAddress getAdditionalGMLCAddress(); + + boolean isPPRAddressAVPPresent(); + java.net.InetAddress getPPRAddress(); + + boolean isRIAFlagsAVPPresent(); + long getRIAFLags(); + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoRequest.java new file mode 100644 index 000000000..1a518687b --- /dev/null +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoRequest.java @@ -0,0 +1,53 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jdiameter.api.slh.events; + +import org.jdiameter.api.app.AppRequestEvent; + +/** + * @author Fernando Mendioroz + * + */ + +/* + * As for 3GPP TS 29.173 v13.0.0, the LCS-Routing-Info-Request (RIR) command, indicated by the Command-Code field set to 8388622 + * and the "R" bit set in the Command Flags field, is sent from GMLC to HSS. The procedure invoked by the GMLC is used for + * retrieving routing information for LCS (Location Services) for a specified user from the HSS. + * + */ +public interface LCSRoutingInfoRequest extends AppRequestEvent { + + String _SHORT_NAME = "RIR"; + String _LONG_NAME = "LCS-Routing-Info-Request"; + + int code = 8388622; + + boolean isUserNameAVPPresent(); // Mapped IE: IMSI + String getUserName(); // Mapped IE: IMSI + + boolean isMSISDNAVPPresent(); + byte[] getMSISDN(); + + boolean isGMLCNumberAVPPresent(); + byte[] getGMLCNumber(); + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/validation/AvpRepresentation.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/validation/AvpRepresentation.java index dc67ef8da..b573ef021 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/validation/AvpRepresentation.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/validation/AvpRepresentation.java @@ -175,8 +175,6 @@ enum Type { int getRuleVendorBitAsInt(); - String getOriginalType(); - String getType(); boolean isProtected(); diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/controller/IRealmTable.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/controller/IRealmTable.java index 0c2824e26..05c3553ee 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/controller/IRealmTable.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/api/controller/IRealmTable.java @@ -43,7 +43,6 @@ package org.jdiameter.client.api.controller; import java.util.Collection; -import java.util.List; import org.jdiameter.api.ApplicationId; import org.jdiameter.api.InternalException; @@ -97,5 +96,4 @@ public interface IRealmTable extends RealmTable { Realm addRealm(String name, ApplicationId appId, LocalAction locAction, IAgentConfiguration agentConfImpl, boolean isDynamic, long expirationTime, String[] hosts) throws InternalException; - List getAllRealmSet(); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/BaseSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/BaseSessionImpl.java index da588a943..cf81b8fb3 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/BaseSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/BaseSessionImpl.java @@ -43,9 +43,7 @@ package org.jdiameter.client.impl; import static org.jdiameter.client.impl.helpers.Parameters.MessageTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.SessionTimeOut; -import java.io.Serializable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -67,14 +65,10 @@ import org.jdiameter.api.OverloadException; import org.jdiameter.api.Request; import org.jdiameter.api.RouteException; -import org.jdiameter.client.api.IAssembler; import org.jdiameter.client.api.IContainer; import org.jdiameter.client.api.IEventListener; import org.jdiameter.client.api.IMessage; import org.jdiameter.client.api.parser.IMessageParser; -import org.jdiameter.common.api.timer.ITimerFacility; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Implementation for {@link BaseSession}. @@ -85,21 +79,15 @@ */ public abstract class BaseSessionImpl implements BaseSession { - private static final Logger logger = LoggerFactory.getLogger(BaseSessionImpl.class); - protected final long creationTime = System.currentTimeMillis(); protected long lastAccessedTime = creationTime; protected boolean isValid = true; protected String sessionId; - protected long maxIdleTime = 0; - protected transient IContainer container; protected transient IMessageParser parser; protected NetworkReqListener reqListener; - protected Serializable istTimerId; - @Override public long getCreationTime() { return creationTime; @@ -110,31 +98,6 @@ public long getLastAccessedTime() { return lastAccessedTime; } - protected long setLastAccessTime() { - lastAccessedTime = System.currentTimeMillis(); - if (sessionId != null) { - maxIdleTime = container.getConfiguration().getLongValue(SessionTimeOut.ordinal(), (Long) SessionTimeOut.defValue()); - if (maxIdleTime > 0) { - IAssembler assembler = container.getAssemblerFacility(); - ITimerFacility timerFacility = assembler.getComponentInstance(ITimerFacility.class); - if (istTimerId != null) { - timerFacility.cancel(istTimerId); - } - istTimerId = timerFacility.schedule(this.getSessionId(), IDLE_SESSION_TIMER_NAME, maxIdleTime); - } - } - return lastAccessedTime; - } - - public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - if (!isValid() || (maxIdleTime > 0 && System.currentTimeMillis() - getLastAccessedTime() >= maxIdleTime)) { - logger.debug("Terminating idle/invalid application session [{}] with SID[{}]", this, getSessionId()); - this.release(); - } - } - } - @Override public boolean isValid() { return isValid; @@ -175,7 +138,7 @@ protected void genericSend(Message message, EventListener listener) protected void genericSend(Message aMessage, EventListener listener, long timeout, TimeUnit timeUnit) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { if (isValid) { - setLastAccessTime(); + lastAccessedTime = System.currentTimeMillis(); IMessage message = (IMessage) aMessage; IEventListener localListener = createListenerWrapper(listener); @@ -439,7 +402,7 @@ public boolean isValid() { @SuppressWarnings("unchecked") public void receivedSuccessMessage(Request request, Answer answer) { if (isValid) { - session.setLastAccessTime(); + session.lastAccessedTime = System.currentTimeMillis(); listener.receivedSuccessMessage(request, answer); } } @@ -448,7 +411,7 @@ public void receivedSuccessMessage(Request request, Answer answer) { @SuppressWarnings("unchecked") public void timeoutExpired(Request message) { if (isValid) { - session.setLastAccessTime(); + session.lastAccessedTime = System.currentTimeMillis(); listener.timeoutExpired(message); } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/RawSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/RawSessionImpl.java index 1b9d34cf9..6c0c272c2 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/RawSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/RawSessionImpl.java @@ -75,7 +75,7 @@ public class RawSessionImpl extends BaseSessionImpl implements RawSession { @Override public Message createMessage(int commandCode, ApplicationId appId, Avp... avps) { if ( isValid ) { - setLastAccessTime(); + lastAccessedTime = System.currentTimeMillis(); IMessage m = parser.createEmptyMessage(commandCode, getAppId(appId)); m.getAvps().addAvp(avps); appendAppId(appId, m); @@ -88,7 +88,7 @@ public Message createMessage(int commandCode, ApplicationId appId, Avp... avps) @Override public Message createMessage(int commandCode, ApplicationId appId, long hopByHopIdentifier, long endToEndIdentifier, Avp... avps) { if ( isValid ) { - setLastAccessTime(); + lastAccessedTime = System.currentTimeMillis(); IMessage m = parser.createEmptyMessage(commandCode, getAppId(appId)); if (hopByHopIdentifier >= 0) { m.setHopByHopIdentifier(-hopByHopIdentifier); @@ -107,7 +107,7 @@ public Message createMessage(int commandCode, ApplicationId appId, long hopByHop @Override public Message createMessage(Message message, boolean copyAvps) { if ( isValid ) { - setLastAccessTime(); + lastAccessedTime = System.currentTimeMillis(); IMessage newMessage = null; IMessage inner = (IMessage) message; if (copyAvps) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionImpl.java index 351164317..4d6dcbae0 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/SessionImpl.java @@ -42,7 +42,6 @@ package org.jdiameter.client.impl; -import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import org.jdiameter.api.Answer; @@ -63,9 +62,6 @@ import org.jdiameter.client.api.ISession; import org.jdiameter.client.api.parser.IMessageParser; import org.jdiameter.common.api.data.ISessionDatasource; -import org.jdiameter.common.api.timer.ITimerFacility; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Implementation for {@link ISession} @@ -76,10 +72,6 @@ */ public class SessionImpl extends BaseSessionImpl implements ISession { - private static final Logger logger = LoggerFactory.getLogger(SessionImpl.class); - - private Semaphore lock = new Semaphore(1); // container lock - SessionImpl(IContainer container) { setContainer(container); try { @@ -91,17 +83,8 @@ public class SessionImpl extends BaseSessionImpl implements ISession { } void setContainer(IContainer container) { - try { - lock.acquire(); // allow container change only if not releasing - this.container = container; - this.parser = (IMessageParser) container.getAssemblerFacility().getComponentInstance(IMessageParser.class); - } - catch (InterruptedException e) { - logger.error("failure getting lock", e); - } - finally { - lock.release(); - } + this.container = container; + this.parser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); } @Override @@ -132,7 +115,7 @@ public NetworkReqListener getReqListener() { @Override public Request createRequest(int commandCode, ApplicationId appId, String destRealm) { if (isValid) { - setLastAccessTime(); + lastAccessedTime = System.currentTimeMillis(); IRequest m = parser.createEmptyMessage(IRequest.class, commandCode, getAppId(appId)); m.setNetworkRequest(false); m.setRequest(true); @@ -152,7 +135,7 @@ public Request createRequest(int commandCode, ApplicationId appId, String destRe @Override public Request createRequest(int commandCode, ApplicationId appId, String destRealm, String destHost) { if (isValid) { - setLastAccessTime(); + lastAccessedTime = System.currentTimeMillis(); IRequest m = parser.createEmptyMessage(IRequest.class, commandCode, getAppId(appId)); m.setNetworkRequest(false); m.setRequest(true); @@ -175,7 +158,7 @@ public Request createRequest(int commandCode, ApplicationId appId, String destRe @Override public Request createRequest(Request prevRequest) { if (isValid) { - setLastAccessTime(); + lastAccessedTime = System.currentTimeMillis(); IRequest request = parser.createEmptyMessage(Request.class, (IMessage) prevRequest); request.setRequest(true); request.setNetworkRequest(false); @@ -190,27 +173,14 @@ public Request createRequest(Request prevRequest) { @Override public void release() { isValid = false; - try { - lock.acquire(); // prevent container NullPointerException - - if (container != null) { - if (istTimerId != null) { - container.getAssemblerFacility().getComponentInstance(ITimerFacility.class).cancel(istTimerId); - } - container.removeSessionListener(sessionId); - container.getAssemblerFacility().getComponentInstance(ISessionDatasource.class).removeSession(sessionId); - } - - container = null; - parser = null; - reqListener = null; - } - catch (InterruptedException e) { - logger.error("failure getting lock", e); - } - finally { - lock.release(); + if (container != null) { + container.removeSessionListener(sessionId); + // FIXME + container.getAssemblerFacility().getComponentInstance(ISessionDatasource.class).removeSession(sessionId); } + container = null; + parser = null; + reqListener = null; } @Override diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/acc/ClientAccSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/acc/ClientAccSessionImpl.java index 5708ce78a..19f1b9c7e 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/acc/ClientAccSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/acc/ClientAccSessionImpl.java @@ -622,10 +622,7 @@ protected void processInterimIntervalAvp(StateEvent event) throws InternalExcept */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_INTERIM)) { + if (timerName.equals(TIMER_NAME_INTERIM)) { if (context != null) { try { Request interimRecord = createInterimRecord(); @@ -644,7 +641,7 @@ else if (timerName.equals(TIMER_NAME_INTERIM)) { } } else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); + //....? } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/auth/ClientAuthSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/auth/ClientAuthSessionImpl.java index 3564e753b..9c118bbc4 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/auth/ClientAuthSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/auth/ClientAuthSessionImpl.java @@ -594,10 +594,7 @@ protected void cancelTsTimer() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_TS)) { + if (timerName.equals(TIMER_NAME_TS)) { try { sendAndStateLock.lock(); sessionData.setTsTimerId(null); @@ -614,9 +611,6 @@ else if (timerName.equals(TIMER_NAME_TS)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cca/ClientCCASessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cca/ClientCCASessionImpl.java index 702b0fdb1..955f0eeba 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cca/ClientCCASessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cca/ClientCCASessionImpl.java @@ -623,15 +623,9 @@ protected void stopTx() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TX_TIMER_NAME)) { + if (timerName.equals(TX_TIMER_NAME)) { new TxTimerTask(this, this.sessionData.getTxTimerRequest()).run(); } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } protected void setState(ClientCCASessionState newState) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cxdx/CxDxClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cxdx/CxDxClientSessionImpl.java index a9b2ea28e..b7226ee1f 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cxdx/CxDxClientSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/cxdx/CxDxClientSessionImpl.java @@ -369,10 +369,7 @@ protected void setState(CxDxSessionState newState) { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(CxDxSession.TIMER_NAME_MSG_TIMEOUT)) { + if (timerName.equals(CxDxSession.TIMER_NAME_MSG_TIMEOUT)) { try { sendAndStateLock.lock(); try { @@ -388,9 +385,6 @@ else if (timerName.equals(CxDxSession.TIMER_NAME_MSG_TIMEOUT)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gq/GqClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gq/GqClientSessionImpl.java index 04443f1c3..02f365002 100755 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gq/GqClientSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gq/GqClientSessionImpl.java @@ -562,10 +562,7 @@ protected void cancelTsTimer() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_TS)) { + if (timerName.equals(TIMER_NAME_TS)) { try { sendAndStateLock.lock(); sessionData.setTsTimerId(null); @@ -582,9 +579,6 @@ else if (timerName.equals(TIMER_NAME_TS)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } protected AbortSessionAnswer createAbortSessionAnswer(Answer answer) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gx/ClientGxSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gx/ClientGxSessionImpl.java index 028a7fb38..c492e970c 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gx/ClientGxSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/gx/ClientGxSessionImpl.java @@ -611,15 +611,9 @@ protected void stopTx() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TX_TIMER_NAME)) { + if (timerName.equals(TX_TIMER_NAME)) { new TxTimerTask(this, this.sessionData.getTxTimerRequest()).run(); } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } protected void setState(ClientGxSessionState newState) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rf/ClientRfSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rf/ClientRfSessionImpl.java index c156e8dd9..04aec79b0 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rf/ClientRfSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rf/ClientRfSessionImpl.java @@ -608,10 +608,7 @@ protected void processInterimIntervalAvp(StateEvent event) throws InternalExcept */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_INTERIM)) { + if (timerName.equals(TIMER_NAME_INTERIM)) { if (context != null) { try { Request interimRecord = createInterimRecord(); @@ -629,9 +626,6 @@ else if (timerName.equals(TIMER_NAME_INTERIM)) { } } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } private void startInterimTimer(long v) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/ro/ClientRoSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/ro/ClientRoSessionImpl.java index ce9f46186..ca41deedb 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/ro/ClientRoSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/ro/ClientRoSessionImpl.java @@ -639,15 +639,9 @@ protected void stopTx() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TX_TIMER_NAME)) { + if (timerName.equals(TX_TIMER_NAME)) { new TxTimerTask(this, sessionData.getTxTimerRequest()).run(); } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } protected void setState(ClientRoSessionState newState) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rx/ClientRxSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rx/ClientRxSessionImpl.java index 97df5be28..b8c4335ab 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rx/ClientRxSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/rx/ClientRxSessionImpl.java @@ -890,11 +890,5 @@ else if (!sessionData.getClientRxSessionState().equals(other.sessionData.getClie @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s13/S13ClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s13/S13ClientSessionImpl.java index 68a61a932..5bbb6f85a 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s13/S13ClientSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s13/S13ClientSessionImpl.java @@ -209,10 +209,7 @@ protected void setState(S13SessionState newState) { @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(S13Session.TIMER_NAME_MSG_TIMEOUT)) { + if (timerName.equals(S13Session.TIMER_NAME_MSG_TIMEOUT)) { try { sendAndStateLock.lock(); try { @@ -226,9 +223,6 @@ else if (timerName.equals(S13Session.TIMER_NAME_MSG_TIMEOUT)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } @Override diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s6a/S6aClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s6a/S6aClientSessionImpl.java index a9aa8fc06..5e16dd246 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s6a/S6aClientSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/s6a/S6aClientSessionImpl.java @@ -371,10 +371,7 @@ protected void setState(S6aSessionState newState) { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(S6aSession.TIMER_NAME_MSG_TIMEOUT)) { + if (timerName.equals(S6aSession.TIMER_NAME_MSG_TIMEOUT)) { try { sendAndStateLock.lock(); try { @@ -390,9 +387,6 @@ else if (timerName.equals(S6aSession.TIMER_NAME_MSG_TIMEOUT)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/sh/ShClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/sh/ShClientSessionImpl.java index ca275c166..aa7d00c37 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/sh/ShClientSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/sh/ShClientSessionImpl.java @@ -291,12 +291,7 @@ public boolean isReplicable() { @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } + // TODO ... } private class RequestDelivery implements Runnable { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/ClientSLgSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/ClientSLgSessionDataLocalImpl.java new file mode 100644 index 000000000..aa207d9e3 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/ClientSLgSessionDataLocalImpl.java @@ -0,0 +1,55 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slg; + +import org.jdiameter.common.impl.app.slg.SLgLocalSessionDataImpl; + +/** + * @author Fernando Mendioroz + * + */ + +public class ClientSLgSessionDataLocalImpl extends SLgLocalSessionDataImpl implements IClientSLgSessionData { + public ClientSLgSessionDataLocalImpl() { + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/Event.java new file mode 100644 index 000000000..f3810dca2 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/Event.java @@ -0,0 +1,107 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slg; + +import org.jdiameter.api.InternalException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateEvent; + +/** + * @author Fernando Mendioroz + * + */ + +public class Event implements StateEvent { + + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_PLA, RECEIVE_LRA; + } + + AppEvent request; + AppEvent answer; + Type type; + + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } + + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } + + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } + + public AppEvent getRequest() { + return request; + } + + public AppEvent getAnswer() { + return answer; + } + + public int compareTo(Object o) { + return 0; + } + + public Object getData() { + return request != null ? request : answer; + } + + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); + } + } +} \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/IClientSLgSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/IClientSLgSessionData.java new file mode 100644 index 000000000..6b1093305 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/IClientSLgSessionData.java @@ -0,0 +1,54 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slg; + +import org.jdiameter.common.api.app.slg.ISLgSessionData; + +/** + * @author Fernando Mendioroz + * + */ + +public interface IClientSLgSessionData extends ISLgSessionData { + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/SLgClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/SLgClientSessionImpl.java new file mode 100644 index 000000000..bcaea2747 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/SLgClientSessionImpl.java @@ -0,0 +1,357 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slg; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.EventListener; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.app.StateEvent; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ClientSLgSessionListener; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.client.impl.app.slg.Event.Type; +import org.jdiameter.common.api.app.slg.ISLgMessageFactory; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.jdiameter.common.impl.app.AppAnswerEventImpl; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.jdiameter.common.impl.app.slg.SLgSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLgClientSessionImpl extends SLgSession + implements ClientSLgSession, EventListener, NetworkReqListener { + + private static final Logger logger = LoggerFactory.getLogger(SLgClientSessionImpl.class); + + private transient ClientSLgSessionListener listener; + + protected long appId = -1; + protected IClientSLgSessionData sessionData; + + public SLgClientSessionImpl(IClientSLgSessionData sessionData, ISLgMessageFactory fct, ISessionFactory sf, + ClientSLgSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); + } + if (fct.getApplicationId() < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); + } + + this.appId = fct.getApplicationId(); + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLgSessionState.class ? (E) this.sessionData.getSLgSessionState() : null; + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + public void sendProvideLocationRequest(ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, request, null); + } + + public void sendLocationReportRequest(LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, request, null); + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); + } + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); + } + } + + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLgSessionState state = this.sessionData.getSLgSessionState(); + SLgSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + switch (state) { + + case IDLE: + switch (eventType) { + + case SEND_MESSAGE: + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + super.session.send(((AppEvent) event.getData()).getMessage(), this); + setState(newState); // FIXME: is this ok to be here? + break; + + default: + logger.error("Invalid Event Type {} for SLg Client Session at state {}.", eventType, + sessionData.getSLgSessionState()); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLgSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLgSessionState.TERMINATED; + setState(newState); + } + break; + + case RECEIVE_PLA: + newState = SLgSessionState.TERMINATED; + setState(newState); + super.cancelMsgTimer(); + listener.doProvideLocationAnswerEvent(this, (ProvideLocationRequest) localEvent.getRequest(), + (ProvideLocationAnswer) localEvent.getAnswer()); + break; + + case RECEIVE_LRA: + newState = SLgSessionState.TERMINATED; + setState(newState); + super.cancelMsgTimer(); + listener.doLocationReportAnswerEvent(this, (LocationReportRequest) localEvent.getRequest(), + (LocationReportAnswer) localEvent.getAnswer()); + break; + + default: + throw new InternalException("Unexpected/Unknown message received: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLg Client FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); + } + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLgSessionState newState) { + SLgSessionState oldState = this.sessionData.getSLgSessionState(); + this.sessionData.setSLgSessionState(newState); + + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); + } + if (newState == SLgSessionState.TERMINATED || newState == SLgSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); + } + } + + public void onTimer(String timerName) { + if (timerName.equals(SLgSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); + try { + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); + } catch (Exception e) { + logger.debug("Failure handling Timeout event."); + } + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + (int) (appId ^ (appId >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + + SLgClientSessionImpl other = (SLgClientSessionImpl) obj; + if (appId != other.appId) { + return false; + } + return true; + } + + @Override + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); + } + } + + private class RequestDelivery implements Runnable { + ClientSLgSession session; + Request request; + + public void run() { + try { + switch (request.getCommandCode()) { + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; + } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } + } + } + + private class AnswerDelivery implements Runnable { + ClientSLgSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + + case ProvideLocationAnswer.code: + handleEvent(new Event(Event.Type.RECEIVE_PLA, messageFactory.createProvideLocationRequest(request), + messageFactory.createProvideLocationAnswer(answer))); + break; + + case LocationReportAnswer.code: + handleEvent(new Event(Event.Type.RECEIVE_LRA, messageFactory.createLocationReportRequest(request), + messageFactory.createLocationReportAnswer(answer))); + break; + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; + } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } + } + } +} \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/ClientSLhSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/ClientSLhSessionDataLocalImpl.java new file mode 100644 index 000000000..633bfd1b6 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/ClientSLhSessionDataLocalImpl.java @@ -0,0 +1,55 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slh; + +import org.jdiameter.common.impl.app.slh.SLhLocalSessionDataImpl; + +/** + * @author Fernando Mendioroz + * + */ + +public class ClientSLhSessionDataLocalImpl extends SLhLocalSessionDataImpl implements IClientSLhSessionData { + public ClientSLhSessionDataLocalImpl() { + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/Event.java new file mode 100644 index 000000000..7702bc0a3 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/Event.java @@ -0,0 +1,106 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slh; + +import org.jdiameter.api.InternalException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateEvent; + +/** + * @author Fernando Mendioroz + * + */ +public class Event implements StateEvent { + + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_RIA; + } + + AppEvent request; + AppEvent answer; + Type type; + + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } + + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } + + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } + + public AppEvent getRequest() { + return request; + } + + public AppEvent getAnswer() { + return answer; + } + + public int compareTo(Object o) { + return 0; + } + + public Object getData() { + return request != null ? request : answer; + } + + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/IClientSLhSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/IClientSLhSessionData.java new file mode 100644 index 000000000..8d6bfe9a0 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/IClientSLhSessionData.java @@ -0,0 +1,54 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slh; + +import org.jdiameter.common.api.app.slh.ISLhSessionData; + +/** + * @author Fernando Mendioroz + * + */ + +public interface IClientSLhSessionData extends ISLhSessionData { + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/SLhClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/SLhClientSessionImpl.java new file mode 100644 index 000000000..8a2165cd7 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/SLhClientSessionImpl.java @@ -0,0 +1,336 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.client.impl.app.slh; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.EventListener; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.app.StateEvent; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ClientSLhSessionListener; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.client.impl.app.slh.Event.Type; +import org.jdiameter.common.api.app.slh.ISLhMessageFactory; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.jdiameter.common.impl.app.AppAnswerEventImpl; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.jdiameter.common.impl.app.slh.SLhSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ +public class SLhClientSessionImpl extends SLhSession + implements ClientSLhSession, EventListener, NetworkReqListener { + + private static final Logger logger = LoggerFactory.getLogger(SLhClientSessionImpl.class); + + private transient ClientSLhSessionListener listener; + + protected long appId = -1; + protected IClientSLhSessionData sessionData; + + public SLhClientSessionImpl(IClientSLhSessionData sessionData, ISLhMessageFactory fct, ISessionFactory sf, + ClientSLhSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); + } + if (fct.getApplicationId() < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); + } + + this.appId = fct.getApplicationId(); + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLhSessionState.class ? (E) this.sessionData.getSLhSessionState() : null; + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + public void sendLCSRoutingInfoRequest(LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, request, null); + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); + } + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); + } + } + + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLhSessionState state = this.sessionData.getSLhSessionState(); + SLhSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + switch (state) { + + case IDLE: + switch (eventType) { + + case SEND_MESSAGE: + newState = SLhSessionState.MESSAGE_SENT_RECEIVED; + super.session.send(((AppEvent) event.getData()).getMessage(), this); + setState(newState); // FIXME: is this ok to be here? + break; + + default: + logger.error("Invalid Event Type {} for SLh Client Session at state {}.", eventType, + sessionData.getSLhSessionState()); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLhSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLhSessionState.TERMINATED; + setState(newState); + } + break; + + case RECEIVE_RIA: + newState = SLhSessionState.TERMINATED; + setState(newState); + super.cancelMsgTimer(); + listener.doLCSRoutingInfoAnswerEvent(this, (LCSRoutingInfoRequest) localEvent.getRequest(), + (LCSRoutingInfoAnswer) localEvent.getAnswer()); + break; + + default: + throw new InternalException("Unexpected/Unknown message received: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLh Client FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); + } + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLhSessionState newState) { + SLhSessionState oldState = this.sessionData.getSLhSessionState(); + this.sessionData.setSLhSessionState(newState); + + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); + } + if (newState == SLhSessionState.TERMINATED || newState == SLhSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); + } + } + + public void onTimer(String timerName) { + if (timerName.equals(SLhSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); + try { + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); + } catch (Exception e) { + logger.debug("Failure handling Timeout event."); + } + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + (int) (appId ^ (appId >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + + SLhClientSessionImpl other = (SLhClientSessionImpl) obj; + if (appId != other.appId) { + return false; + } + return true; + } + + @Override + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); + } + } + + private class RequestDelivery implements Runnable { + ClientSLhSession session; + Request request; + + public void run() { + try { + switch (request.getCommandCode()) { + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; + } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } + } + } + + private class AnswerDelivery implements Runnable { + ClientSLhSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + + case LCSRoutingInfoAnswer.code: + handleEvent(new Event(Event.Type.RECEIVE_RIA, messageFactory.createLCSRoutingInfoRequest(request), + messageFactory.createLCSRoutingInfoAnswer(answer))); + break; + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; + } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } + } + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/PeerTableImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/PeerTableImpl.java index 964eb5caf..cb3b19c15 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/PeerTableImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/PeerTableImpl.java @@ -211,8 +211,8 @@ public void sendMessage(IMessage message) throws IllegalDiameterStateException, else { logger.debug("Message is an answer"); peer = message.getPeer(); - if (peer == null || !peer.hasValidConnection()) { - logger.debug("Peer is null [{}] or with invalid connection so we will use router.getPeer to find a peer", peer == null); + if (peer == null) { + logger.debug("Peer is null so we will use router.getPeer to find a peer"); peer = router.getPeer(message, this); if (peer == null) { throw new RouteException( "Cannot found remote context for sending message" ); diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/RealmTableImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/RealmTableImpl.java index 2b50893d6..dbd2d7aa1 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/RealmTableImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/controller/RealmTableImpl.java @@ -200,7 +200,7 @@ public Collection getRealms(String realmName) { Collection present = set.values(); return new ArrayList(present); } - return new ArrayList(0); + return null; } /* @@ -443,9 +443,4 @@ public T unwrap(Class iface) throws InternalException { return null; } - @Override - public List getAllRealmSet() { - return allRealmsSet; - } - } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/helpers/Parameters.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/helpers/Parameters.java index 2224a63c2..cb568947d 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/helpers/Parameters.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/helpers/Parameters.java @@ -123,10 +123,6 @@ public class Parameters extends Ordinal { * Reconnect time out property */ public static final Parameters RecTimeOut = new Parameters("RecTimeOut", Long.class, 10000L); - /** - * Idle session time out property - */ - public static final Parameters SessionTimeOut = new Parameters("SessionTimeOut", Long.class, 0L); /** * Peer FSM Thread Count property diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpImpl.java index 4ed2aa6a3..7898930b0 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpImpl.java @@ -295,8 +295,8 @@ public byte[] getRawData() { @Override public String toString() { if (toString == null) { - this.toString = new StringBuffer("AvpImpl [avpCode=").append(avpCode).append(", vendorID=").append(vendorID). - append(", len=").append((rawData != null) ? rawData.length : null).append("]@").append(super.hashCode()).toString(); + this.toString = new StringBuffer("AvpImpl [avpCode=").append(avpCode).append(", vendorID=").append(vendorID).append("]@").append(super.hashCode()). + toString(); } return this.toString; diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpSetImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpSetImpl.java index a20e719d7..800fe3f5c 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpSetImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/AvpSetImpl.java @@ -68,7 +68,6 @@ * @author erick.svenson@yahoo.com * @author Alexandre Mendonca * @author Bartosz Baranowski - * @author Grzegorz Figiel [ProIDS] */ class AvpSetImpl implements AvpSet { @@ -133,26 +132,6 @@ public AvpSet getAvps(int avpCode, long vendorId) { return result; } - @Override - public int getAvpIndex(int avpCode) { - for (Avp avp : this.avps) { - if (avp.getCode() == avpCode) { - return this.avps.indexOf(avp); - } - } - return -1; - } - - @Override - public int getAvpIndex(int avpCode, long vendorId) { - for (Avp avp : this.avps) { - if (avp.getCode() == avpCode && avp.getVendorId() == vendorId) { - return this.avps.indexOf(avp); - } - } - return -1; - } - @Override public AvpSet removeAvp(int avpCode) { return removeAvp(avpCode, 0); @@ -240,7 +219,7 @@ public Avp insertAvp(int index, int avpCode, long value, boolean mFlag, boolean public Avp insertAvp(int index, int avpCode, long value, long vndId, boolean mFlag, boolean pFlag, boolean asUnsigned) { int flags = ((vndId != 0 ? 0x80 : 0) | (mFlag ? 0x40 : 0) | (pFlag ? 0x20 : 0)); Avp res = new AvpImpl(avpCode, flags, vndId, asUnsigned ? parser.intU32ToBytes(value) : parser.int64ToBytes(value)); - this.avps.add(index, res); + this.avps.add(res); return res; } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/ElementParser.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/ElementParser.java index 80a4c35a6..3bad9b167 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/ElementParser.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/ElementParser.java @@ -286,13 +286,11 @@ public AvpSetImpl decodeAvpSet(byte[] buffer, int shift) throws IOException, Avp throw new AvpDataException("Not enough data in buffer!"); } long vendor = 0; - boolean hasVendor = false; if ((flags & 0x80) != 0) { vendor = in.readInt(); - hasVendor = true; } // Determine body L = length - 4(code) -1(flags) -3(length) [-4(vendor)] - byte[] rawData = new byte[length - (8 + (hasVendor ? 4 : 0))]; + byte[] rawData = new byte[length - (8 + (vendor == 0 ? 0 : 4))]; in.read(rawData); // skip remaining. // TODO: Do we need to padd everything? Or on send stack should properly fill byte[] ... ? diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/MessageParser.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/MessageParser.java index e658247d9..b46f59041 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/MessageParser.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/parser/MessageParser.java @@ -250,40 +250,6 @@ void copyBasicAvps(IMessage newMessage, IMessage prnMessage, boolean invertPoint } } - public static String byteArrayToHexString(byte[] in, boolean columnize) { - if (in == null || in.length <= 0) { - return ""; - } - String pseudo = "0123456789ABCDEF"; - - StringBuffer out = new StringBuffer(in.length * 3); - - for (int i = 0; i < in.length; i++) { - byte ch = in[i]; - out.append(pseudo.charAt((int) ((ch & 0xF0) >> 4))); - out.append(pseudo.charAt((int) (ch & 0x0F))); - - if (columnize) { - if ((i + 1) % 16 == 0) { - out.append("\n"); - } - else if ((i + 1) % 4 == 0) { - out.append(" "); - } - } - } - - return out.toString(); - } - - public static String byteArrayToHexStringLine(byte[] in) { - return byteArrayToHexString(in, false); - } - - public static String byteArrayToHexString(byte[] in) { - return byteArrayToHexString(in, true); - } - @Override public ByteBuffer encodeMessage(IMessage message) throws ParseException { ByteArrayOutputStream out = new ByteArrayOutputStream(); diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/router/RouterImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/router/RouterImpl.java index 7d72d50f4..09d4cfee1 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/router/RouterImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/router/RouterImpl.java @@ -256,27 +256,9 @@ public void registerRequestRouteInfo(IRequest request) { // requestEntryTableLock.writeLock().lock(); long hopByHopId = request.getHopByHopIdentifier(); Avp hostAvp = request.getAvps().getAvp(Avp.ORIGIN_HOST); - // we store the peer FQDN instead of Origin-Host as we want to route back to it, in case of proxied requests this - // should be the FQDN of the proxy, otherwise it's (should be) the same as Origin-Host - String host = ((IMessage)request).getPeer() != null ? ((IMessage)request).getPeer().getUri().getFQDN() : hostAvp.getDiameterIdentity(); Avp realmAvp = request.getAvps().getAvp(Avp.ORIGIN_REALM); - - AnswerEntry entry; - AvpSet rrAvps = request.getAvps().getAvps(Avp.ROUTE_RECORD); - if (rrAvps.size() > 0) { - logger.debug("Found [{}] Route-Record AVP(s) in Request with HbH [{}], storing them for copying and routing.", - rrAvps.size(), request.getHopByHopIdentifier()); - ArrayList rrStrings = new ArrayList(); - for(Avp rrAvp : rrAvps) { - String rrAvpHost = rrAvp.getDiameterIdentity(); - logger.trace("Route-Record in Request with HbH [{}]: [{}]", request.getHopByHopIdentifier(), rrAvpHost); - rrStrings.add(rrAvpHost); - } - entry = new AnswerEntry(hopByHopId, host, realmAvp != null ? realmAvp.getDiameterIdentity() : null, rrStrings); - } - else { - entry = new AnswerEntry(hopByHopId, host, realmAvp != null ? realmAvp.getDiameterIdentity() : null); - } + AnswerEntry entry = new AnswerEntry(hopByHopId, hostAvp != null ? hostAvp.getDiameterIdentity() : null, + realmAvp != null ? realmAvp.getDiameterIdentity() : null); int s = requestEntryMap.size(); // PCB added logging @@ -311,7 +293,7 @@ public void registerRequestRouteInfo(IRequest request) { } String messageKey = makeRoutingKey(request); - logger.debug("Adding request key [{}] to RequestRoute map with entry [{}] for routing answers back to the requesting peer", messageKey, entry); + logger.debug("Adding request key [{}] to RequestRoute map for routing answers back to the requesting peer", messageKey); requestEntryMap.put(messageKey, entry); // requestSortedEntryTable.add(hopByHopId); } @@ -330,10 +312,10 @@ private String makeRoutingKey(Message message) { .append(message.getHopByHopIdentifier()).toString(); } - private String[] getRequestRouteInfoAndCopyProxyAvps(IMessage message, boolean copy) { + @Override + public String[] getRequestRouteInfo(IMessage message) { if (REQUEST_TABLE_SIZE == 0) { return ((MessageImpl) message).getRoutingInfo(); // using answer stored routing info - // TODO: Handle copy Proxy AVPs in this case... } // using request table @@ -343,18 +325,7 @@ private String[] getRequestRouteInfoAndCopyProxyAvps(IMessage message, boolean c if (logger.isDebugEnabled()) { logger.debug("getRequestRouteInfo found host [{}] and realm [{}] for Message key Id [{}]", new Object[]{ans.getHost(), ans.getRealm(), messageKey}); } - if (ans.getRouteRecords() != null && ans.getRouteRecords().size() > 0) { - AvpSet msgRouteRecords = message.getAvps().getAvps(Avp.ROUTE_RECORD); - if (msgRouteRecords.size() > 0) { - logger.debug("We had Route-Records to insert but the message already has some... not doing anything"); - } - else { - for (String rr : ans.getRouteRecords()) { - message.getAvps().addAvp(Avp.ROUTE_RECORD, rr, true); - } - } - } - return new String[] { ans.getHost(), ans.getRealm() }; + return new String[] {ans.getHost(), ans.getRealm()}; } else { if (logger.isWarnEnabled()) { @@ -364,11 +335,6 @@ private String[] getRequestRouteInfoAndCopyProxyAvps(IMessage message, boolean c } } - @Override - public String[] getRequestRouteInfo(IMessage message) { - return getRequestRouteInfoAndCopyProxyAvps(message, false); - } - //PCB added @Override public void garbageCollectRequestRouteInfo(IMessage message) { @@ -409,39 +375,24 @@ public IPeer getPeer(IMessage message, IPeerTable manager) throws RouteException } else { //answer, search - info = getRequestRouteInfoAndCopyProxyAvps(message, true); - - // check for route-record AVPs - AvpSet rrAvps = message.getAvps().getAvps(Avp.ROUTE_RECORD); - if (rrAvps.size() > 0) { - // we want to send it back to the last - Avp destHostAvp = rrAvps.getAvpByIndex(rrAvps.size()-1); - logger.debug("Got Route-Record AVP to route the answer with HbH [{}] to: [{}]", message.getHopByHopIdentifier(), destHostAvp.getDiameterIdentity()); - - String matchedRealmName = this.realmTable.getRealmForPeer(destHostAvp.getDiameterIdentity()); - logger.debug("Got a Realm for the answer with HbH [{}] routing via Route-Record: [{}]", message.getHopByHopIdentifier(), matchedRealmName); - - matchedRealm = (IRealm) this.realmTable.matchRealm((IAnswer) message, matchedRealmName); + info = getRequestRouteInfo(message); + if (info != null) { + destHost = info[0]; + destRealm = info[1]; + logger.debug("Message is an answer. Host is [{}] and Realm is [{}] as per hopbyhop info from request", destHost, destRealm); + if (destRealm == null) { + logger.warn("Destination-Realm was null for hopbyhop id " + message.getHopByHopIdentifier()); + } } else { - if (info != null) { - destHost = info[0]; - destRealm = info[1]; - logger.debug("Message is an answer. Host is [{}] and Realm is [{}] as per hopbyhop info from request", destHost, destRealm); - if (destRealm == null) { - logger.warn("Destination-Realm was null for hopbyhop id " + message.getHopByHopIdentifier()); - } - } - else { - logger.debug("No Host and realm found based on hopbyhop id of the answer associated request"); - } - //FIXME: if no info, should not send it ? - //FIXME: add strict deff in route back table so stack does not have to lookup? - if (logger.isDebugEnabled()) { - logger.debug("Looking up peer for answer: [{}], DestHost=[{}], DestRealm=[{}]", new Object[] {message, destHost, destRealm}); - } - matchedRealm = (IRealm) this.realmTable.matchRealm((IAnswer) message, destRealm); + logger.debug("No Host and realm found based on hopbyhop id of the answer associated request"); } + //FIXME: if no info, should not send it ? + //FIXME: add strict deff in route back table so stack does not have to lookup? + if (logger.isDebugEnabled()) { + logger.debug("Looking up peer for answer: [{}], DestHost=[{}], DestRealm=[{}]", new Object[] {message, destHost, destRealm}); + } + matchedRealm = (IRealm) this.realmTable.matchRealm(message, destRealm); } // IPeer peer = getPeerPredProcessing(message, destRealm, destHost); @@ -452,14 +403,9 @@ public IPeer getPeer(IMessage message, IPeerTable manager) throws RouteException // } // Check realm name + //TODO: check only if it exists? if (matchedRealm == null) { - if (message.getAvps().getAvp(Avp.ROUTE_RECORD) == null) { - // if it doesn't come through a proxy, we fail with unknown realm... - throw new RouteException("Unknown realm name [" + destRealm + "]"); - } - else { - logger.debug("Realm [{}] not found, but message has Route-Record AVP so it came from proxy peer [{}]. Proceeding...", destRealm, destHost); - } + throw new RouteException("Unknown realm name [" + destRealm + "]"); } // THIS IS GET PEER, NOT ROUTE!!!!!!! @@ -960,7 +906,6 @@ protected class AnswerEntry { final long createTime = System.nanoTime(); Long hopByHopId; String host, realm; - ArrayList routeRecords; public AnswerEntry(Long hopByHopId) { this.hopByHopId = hopByHopId; @@ -972,13 +917,6 @@ public AnswerEntry(Long hopByHopId, String host, String realm) throws InternalEr this.realm = realm; } - public AnswerEntry(Long hopByHopId, String host, String realm, ArrayList routeRecords) throws InternalError { - this.hopByHopId = hopByHopId; - this.host = host; - this.realm = realm; - this.routeRecords = routeRecords; - } - public long getCreateTime() { return createTime; } @@ -995,10 +933,6 @@ public String getRealm() { return realm; } - public ArrayList getRouteRecords() { - return routeRecords; - } - @Override public int hashCode() { return super.hashCode(); @@ -1018,7 +952,7 @@ public boolean equals(Object o) { @Override public String toString() { - return "AnswerEntry {" + "createTime=" + createTime + ", hopByHopId=" + hopByHopId + ", host=" + host + ", realm=" + realm+ "}"; + return "AnswerEntry {" + "createTime=" + createTime + ", hopByHopId=" + hopByHopId + '}'; } } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPClientConnection.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPClientConnection.java index e9e3243b3..10521c373 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPClientConnection.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPClientConnection.java @@ -63,7 +63,6 @@ import org.jdiameter.client.api.io.TransportError; import org.jdiameter.client.api.io.TransportException; import org.jdiameter.client.api.parser.IMessageParser; -import org.jdiameter.client.impl.parser.MessageParser; import org.jdiameter.common.api.concurrent.IConcurrentFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -299,13 +298,7 @@ protected void onDisconnect() throws AvpDataException { protected void onMessageReceived(ByteBuffer message) throws AvpDataException { if (logger.isDebugEnabled()) { - if (logger.isTraceEnabled()) { - String hex = MessageParser.byteArrayToHexString(message.array()); - logger.trace("Received message of size [{}]\n{}", new Object[] { message.array().length, hex }); - } - else { - logger.debug("Received message of size [{}]", message.array().length); - } + logger.debug("Received message of size [{}]", message.array().length); } onEvent(new Event(EventType.MESSAGE_RECEIVED, message)); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPTransportClient.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPTransportClient.java index 6fc1aa398..88d619226 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPTransportClient.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/transport/tcp/TCPTransportClient.java @@ -60,7 +60,6 @@ import org.jdiameter.api.AvpDataException; import org.jdiameter.client.api.io.NotInitializedException; -import org.jdiameter.client.impl.parser.MessageParser; import org.jdiameter.common.api.concurrent.IConcurrentFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,24 +124,13 @@ public void initialize() throws IOException, NotInitializedException { throw new NotInitializedException("Destination address is not set"); } socketChannel = SelectorProvider.provider().openSocketChannel(); - - try { - if (origAddress != null) { - socketChannel.socket().bind(origAddress); - } - - socketChannel.connect(destAddress); - //PCB added logging - socketChannel.configureBlocking(BLOCKING_IO); - getParent().onConnected(); - } - catch (IOException e) { - if (origAddress != null) { - socketChannel.socket().close(); - } - socketChannel.close(); - throw e; + if (origAddress != null) { + socketChannel.socket().bind(origAddress); } + socketChannel.connect(destAddress); + //PCB added logging + socketChannel.configureBlocking(BLOCKING_IO); + getParent().onConnected(); } public TCPClientConnection getParent() { @@ -304,14 +292,7 @@ public InetSocketAddress getOrigAddress() { public void sendMessage(ByteBuffer bytes) throws IOException { if (logger.isDebugEnabled()) { - if (logger.isTraceEnabled()) { - String hex = MessageParser.byteArrayToHexString(bytes.array()); - logger.trace("About to send a byte buffer of size [{}] over the TCP nio socket [{}]\n{}", - new Object[]{bytes.array().length, socketDescription, hex}); - } - else { - logger.debug("About to send a byte buffer of size [{}] over the TCP nio socket [{}]", bytes.array().length, socketDescription); - } + logger.debug("About to send a byte buffer of size [{}] over the TCP nio socket [{}]", bytes.array().length, socketDescription); } int rc = 0; // PCB - removed locking @@ -332,9 +313,6 @@ public void sendMessage(ByteBuffer bytes) throws IOException { if (rc == -1) { throw new IOException("Connection closed"); } - else if (rc == 0) { - logger.error("socketChannel.write(bytes) - returned zero indicating that perhaps the write buffer is full"); - } if (logger.isDebugEnabled()) { logger.debug("Sent a byte buffer of size [{}] over the TCP nio socket [{}]", bytes.array().length, socketDescription); } @@ -414,7 +392,6 @@ private boolean seekMessage() { // ZhixiaoLuo: fix #28, if unlucky storage.limit < data.length(1024), then always failed to do storage.put(data) // ZhixiaoLuo: and get BufferOverflowException in append(data) storage.clear(); - logger.error("Invalid message version detected [" + vers + "]"); return false; } // extract the message length, so we know how much to read diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgMessageFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgMessageFactory.java new file mode 100644 index 000000000..79328249a --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgMessageFactory.java @@ -0,0 +1,73 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slg; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.Request; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.api.slg.events.ProvideLocationRequest; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ISLgMessageFactory { + + ProvideLocationRequest createProvideLocationRequest(Request request); + + ProvideLocationAnswer createProvideLocationAnswer(Answer answer); + + LocationReportRequest createLocationReportRequest(Request request); + + LocationReportAnswer createLocationReportAnswer(Answer answer); + + /** + * Returns the Application-Id that this message factory is related to + * + * @return the Application-Id value + */ + long getApplicationId(); +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java new file mode 100644 index 000000000..72fab6e11 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java @@ -0,0 +1,68 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slg; + +import java.io.Serializable; + +import org.jdiameter.api.Request; +import org.jdiameter.common.api.app.IAppSessionData; + +/** + * @author Fernando Mendioroz + * + */ +public interface ISLgSessionData extends IAppSessionData { + + void setSLgSessionState(SLgSessionState state); + + SLgSessionState getSLgSessionState(); + + Serializable getTsTimerId(); + + void setTsTimerId(Serializable tid); + + void setBuffer(Request buffer); + + Request getBuffer(); + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionFactory.java new file mode 100644 index 000000000..dbf8205b0 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionFactory.java @@ -0,0 +1,111 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slg; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.slg.ClientSLgSessionListener; +import org.jdiameter.api.slg.ServerSLgSessionListener; +import org.jdiameter.common.api.app.IAppSessionFactory; +// import org.jdiameter.common.api.app.slg.ISLgMessageFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ISLgSessionFactory extends IAppSessionFactory { + + /** + * Get stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @return the serverSessionListener + */ + ServerSLgSessionListener getServerSessionListener(); + + /** + * Set stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @param serverSessionListener the serverSessionListener to set + */ + void setServerSessionListener(ServerSLgSessionListener serverSessionListener); + + /** + * Get stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @return the clientSessionListener + */ + ClientSLgSessionListener getClientSessionListener(); + + /** + * Set stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @param clientSessionListener the clientSessionListener to set + */ + void setClientSessionListener(ClientSLgSessionListener clientSessionListener); + + /** + * @return the messageFactory + */ + ISLgMessageFactory getMessageFactory(); + + /** + * @param messageFactory the messageFactory to set + */ + void setMessageFactory(ISLgMessageFactory messageFactory); + + /** + * @return the stateListener + */ + StateChangeListener getStateListener(); + + /** + * @param stateListener the stateListener to set + */ + void setStateListener(StateChangeListener stateListener); + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/SLgSessionState.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/SLgSessionState.java new file mode 100644 index 000000000..5c4d32e2f --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/SLgSessionState.java @@ -0,0 +1,54 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slg; + +/** + * @author Fernando Mendioroz + * + */ + +public enum SLgSessionState { + + IDLE, MESSAGE_SENT_RECEIVED, TERMINATED, TIMEDOUT; + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhMessageFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhMessageFactory.java new file mode 100644 index 000000000..ded2d6d59 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhMessageFactory.java @@ -0,0 +1,68 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slh; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.Request; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ISLhMessageFactory { + + LCSRoutingInfoRequest createLCSRoutingInfoRequest(Request request); + + LCSRoutingInfoAnswer createLCSRoutingInfoAnswer(Answer answer); + + /** + * Returns the Application-Id that this message factory is related to + * + * @return the Application-Id value + */ + long getApplicationId(); + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionData.java new file mode 100644 index 000000000..1f16afce7 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionData.java @@ -0,0 +1,69 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slh; + +import java.io.Serializable; + +import org.jdiameter.api.Request; +import org.jdiameter.common.api.app.IAppSessionData; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ISLhSessionData extends IAppSessionData { + + void setSLhSessionState(SLhSessionState state); + + SLhSessionState getSLhSessionState(); + + Serializable getTsTimerId(); + + void setTsTimerId(Serializable tid); + + void setBuffer(Request buffer); + + Request getBuffer(); + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionFactory.java new file mode 100644 index 000000000..e05d98ebf --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionFactory.java @@ -0,0 +1,111 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slh; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.slh.ClientSLhSessionListener; +import org.jdiameter.api.slh.ServerSLhSessionListener; +import org.jdiameter.common.api.app.IAppSessionFactory; +// import org.jdiameter.common.api.app.slh.ISLhMessageFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public interface ISLhSessionFactory extends IAppSessionFactory { + + /** + * Get stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @return the serverSessionListener + */ + ServerSLhSessionListener getServerSessionListener(); + + /** + * Set stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @param serverSessionListener the serverSessionListener to set + */ + void setServerSessionListener(ServerSLhSessionListener serverSessionListener); + + /** + * Get stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @return the clientSessionListener + */ + ClientSLhSessionListener getClientSessionListener(); + + /** + * Set stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @param clientSessionListener the clientSessionListener to set + */ + void setClientSessionListener(ClientSLhSessionListener clientSessionListener); + + /** + * @return the messageFactory + */ + ISLhMessageFactory getMessageFactory(); + + /** + * @param messageFactory the messageFactory to set + */ + void setMessageFactory(ISLhMessageFactory messageFactory); + + /** + * @return the stateListener + */ + StateChangeListener getStateListener(); + + /** + * @param stateListener the stateListener to set + */ + void setStateListener(StateChangeListener stateListener); + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/SLhSessionState.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/SLhSessionState.java new file mode 100644 index 000000000..62e1cf6bc --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/SLhSessionState.java @@ -0,0 +1,54 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.api.app.slh; + +/** + * @author Fernando Mendioroz + * + */ + +public enum SLhSessionState { + + IDLE, MESSAGE_SENT_RECEIVED, TERMINATED, TIMEDOUT; + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/AppSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/AppSessionImpl.java index 69151514a..6b094258a 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/AppSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/AppSessionImpl.java @@ -42,8 +42,6 @@ package org.jdiameter.common.impl.app; -import static org.jdiameter.client.impl.helpers.Parameters.SessionTimeOut; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -82,8 +80,6 @@ public abstract class AppSessionImpl implements AppSession { protected ITimerFacility timerFacility; - protected long maxIdleTime = 0; - public AppSessionImpl(ISessionFactory sf, IAppSessionData appSessionData) { if (sf == null) { throw new IllegalArgumentException("SessionFactory must not be null"); @@ -98,7 +94,6 @@ public AppSessionImpl(ISessionFactory sf, IAppSessionData appSessionData) { this.scheduler = assembler.getComponentInstance(IConcurrentFactory.class). getScheduledExecutorService(IConcurrentFactory.ScheduledExecServices.ApplicationSession.name()); this.timerFacility = assembler.getComponentInstance(ITimerFacility.class); - this.maxIdleTime = this.sf.getContainer().getConfiguration().getLongValue(SessionTimeOut.ordinal(), (Long) SessionTimeOut.defValue()); this.session = this.sf.getNewSession(this.appSessionData.getSessionId()); //annoying ;[ ArrayList list = new ArrayList(); @@ -207,12 +202,4 @@ public boolean equals(Object obj) { public abstract void onTimer(String timerName); - protected void checkIdleAppSession() { - if (!isValid() || (maxIdleTime > 0 && System.currentTimeMillis() - getLastAccessedTime() >= maxIdleTime)) { - logger.debug("Terminating idle/invalid application session [{}] with SID[{}]", this, getSessionId()); - release(); - } - } - - } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java new file mode 100644 index 000000000..83d8b6b07 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java @@ -0,0 +1,245 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import org.jdiameter.api.Avp; +import org.jdiameter.api.Answer; +import org.jdiameter.api.Request; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public class LocationReportAnswerImpl extends AppRequestEventImpl implements LocationReportAnswer { + + private static final long serialVersionUID = 1L; + + protected static final Logger logger = LoggerFactory.getLogger(LocationReportAnswerImpl.class); + + /** + * + * @param answer + */ + public LocationReportAnswerImpl(Answer answer) { + super(answer); + } + + /** + * + * @param request + * @param resultCode + */ + public LocationReportAnswerImpl(Request request, long resultCode) { + super(request.createAnswer(resultCode)); + } + + public Avp getResultCodeAvp() throws AvpDataException { + return null; + } + + @Override + public boolean isGMLCAddressAvpPresent(){ + return super.message.getAvps().getAvp(Avp.GMLC_ADDRESS) != null; + } + + @Override + public java.net.InetAddress getGMLCAddress(){ + Avp lcsGMLCAddressAvp = super.message.getAvps().getAvp(Avp.GMLC_ADDRESS); + if (lcsGMLCAddressAvp != null) { + try { + return lcsGMLCAddressAvp.getAddress(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isLRAFlagsAvpPresent(){ + return super.message.getAvps().getAvp(Avp.LRA_FLAGS) != null; + } + + @Override + public long getLRAFLags(){ + Avp lcsLRAFlagsAvp = super.message.getAvps().getAvp(Avp.LRA_FLAGS); + if (lcsLRAFlagsAvp != null) { + try { + return lcsLRAFlagsAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS LRA Flags AVP value", e); + } + } + return -1; + } + + @Override + public boolean isReportingPLMNListAvpPresent(){ + return super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST) != null; + } + + @Override + public boolean isPrioritizedListIndicatorAvpPresent(){ + Avp lcsReportingPLMNListAvp = super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST); + if (lcsReportingPLMNListAvp != null) { + try { + return lcsReportingPLMNListAvp.getGrouped().getAvp(Avp.PRIORITIZED_LIST_INDICATOR) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Prioritized-List-Indicator AVP", e); + } + } + return false; + } + + @Override + public int getPrioritizedListIndicator(){ + Avp lcsReportingPLMNListAvp = super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST); + if (lcsReportingPLMNListAvp != null) { + try { + Avp lcsPrioritizedListIndicatorAvp = lcsReportingPLMNListAvp.getGrouped().getAvp(Avp.PRIORITIZED_LIST_INDICATOR); + if (lcsPrioritizedListIndicatorAvp != null){ + return lcsPrioritizedListIndicatorAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-Positioning-Data AVP value", e); + } + } + return -1; + } + + @Override + public boolean isPLMNIDListAvpPresent(){ + Avp lcsReportingPLMNListAvp = super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST); + if (lcsReportingPLMNListAvp != null) { + try { + return lcsReportingPLMNListAvp.getGrouped().getAvp(Avp.PLMN_ID_LIST) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain PLMN-Id-List AVP", e); + } + } + return false; + } + + @Override + public boolean isVisitedPLMNIdAvpPresent(){ + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + return lcsPLMNIdListAvp.getGrouped().getAvp(Avp.VISITED_PLMN_ID) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Visited-PLMN-Id AVP", e); + } + } + return false; + } + + @Override + public byte[] getVisitedPLMNId() { + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + Avp lcsVisitedPLMNIdAvp = lcsPLMNIdListAvp.getGrouped().getAvp(Avp.VISITED_PLMN_ID); + if (lcsVisitedPLMNIdAvp != null){ + return lcsVisitedPLMNIdAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Visited PLMN ID AVP value", e); + } + } + return null; + } + + @Override + public boolean isPeriodicLocationSupportIndicatorAvpPresent(){ + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + return lcsPLMNIdListAvp.getGrouped().getAvp(Avp.PERIODIC_LOCATION_SUPPORT_INDICATOR) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Periodic-Location-Support-Indicator AVP", e); + } + } + return false; + } + + @Override + public int getPeriodicLocationSupportIndicator() { + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + Avp lcsPeriodicLocationSupportIndicatorAvp = lcsPLMNIdListAvp.getGrouped().getAvp(Avp.PERIODIC_LOCATION_SUPPORT_INDICATOR); + if (lcsPeriodicLocationSupportIndicatorAvp != null){ + return lcsPeriodicLocationSupportIndicatorAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Periodic Location Support Indicator AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSReferenceNumberAvpPresent(){ + return super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER) != null; + } + + @Override + public byte[] getLCSReferenceNumber(){ + Avp lcsLCSReferenceNumberAvp = super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER); + if (lcsLCSReferenceNumberAvp != null) { + try { + return lcsLCSReferenceNumberAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reference Number AVP value", e); + } + } + return null; + } + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportRequestImpl.java new file mode 100644 index 000000000..0b15b736c --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportRequestImpl.java @@ -0,0 +1,1176 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.Message; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ +public class LocationReportRequestImpl extends AppRequestEventImpl implements LocationReportRequest { + + private static final long serialVersionUID = 1L; + + protected static final Logger logger = LoggerFactory.getLogger(LocationReportRequestImpl.class); + + public LocationReportRequestImpl(Message message) { + super(message); + message.setRequest(true); + } + + @Override + public boolean isLocationEventAvpPresent() { + return super.message.getAvps().getAvp(Avp.LOCATION_EVENT) != null; + } + + @Override + public int getLocationEvent() { + Avp slgLocationEventAvp = super.message.getAvps().getAvp(Avp.LOCATION_EVENT); + if (slgLocationEventAvp != null) { + try { + return slgLocationEventAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Location-Event AVP value", e); + } + } + return -1; + } + + @Override + public boolean isUserNameAvpPresent() { + return super.message.getAvps().getAvp(Avp.USER_NAME) != null; // IE: IMSI + } + + @Override + public String getUserName() { + Avp userNameAvp = super.message.getAvps().getAvp(Avp.USER_NAME); + if (userNameAvp != null) { + try { + return userNameAvp.getUTF8String(); // IE: IMSI mapped to User-Name + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain User-Name AVP value (IMSI)", e); + } + } + return null; + } + + @Override + public boolean isMSISDNAvpPresent() { + return super.message.getAvps().getAvp(Avp.MSISDN) != null; + } + + @Override + public byte[] getMSISDN() { + Avp msisdnAvp = super.message.getAvps().getAvp(Avp.MSISDN); + if (msisdnAvp != null) { + try { + return msisdnAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSISDN AVP value", e); + } + } + return null; + } + + @Override + public boolean isIMEIAvpPresent() { + return super.message.getAvps().getAvp(Avp.TGPP_IMEI) != null; + } + + @Override + public String getIMEI() { + Avp imeiAvp = super.message.getAvps().getAvp(Avp.TGPP_IMEI); + if (imeiAvp != null) { + try { + return imeiAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain IMEI AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSEPSClientNameAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME) != null; + } + + @Override + public boolean isLSCNameStringAvpPresent() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + return lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_NAME_STRING) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Name-String AVP", e); + } + } + return false; + } + + @Override + public String getLSCNameString() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + Avp lcsNameStringAvp = lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_NAME_STRING); + if (lcsNameStringAvp != null){ + return lcsNameStringAvp.getUTF8String(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Name-String AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSFormatIndicatorAvpPresent() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + return lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_FORMAT_INDICATOR) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Format-Indicator AVP", e); + } + } + return false; + } + + @Override + public int getLCSFormatIndicator() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + Avp lcsFormatIndicatorAvp = lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_FORMAT_INDICATOR); + if (lcsFormatIndicatorAvp != null){ + return lcsFormatIndicatorAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Format-Indicator AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLocationEstimateAvpPresent() { + return super.message.getAvps().getAvp(Avp.LOCATION_ESTIMATE) != null; + } + + @Override + public byte[] getLocationEstimate() { + Avp lcsLocationEstimateAvp = super.message.getAvps().getAvp(Avp.LOCATION_ESTIMATE); + if (lcsLocationEstimateAvp != null) { + try { + return lcsLocationEstimateAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Location-Estimate AVP value", e); + } + } + return null; + } + + @Override + public boolean isAccuracyFulfilmentIndicatorAvpPresent() { + return super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR) != null; + } + + @Override + public int getAccuracyFulfilmentIndicator() { + Avp lcsAccuracyFulfilmentIndAvp = super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR); + if (lcsAccuracyFulfilmentIndAvp != null) { + try { + return lcsAccuracyFulfilmentIndAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Accuracy fulfilment indicator AVP value", e); + } + } + return -1; + } + + @Override + public boolean isAgeOfLocationEstimateAvpPresent() { + return super.message.getAvps().getAvp(Avp.AGE_OF_LOCATION_ESTIMATE) != null; + } + + @Override + public long getAgeOfLocationEstimate() { + Avp lcsAgeOfLocEstimateAvp = super.message.getAvps().getAvp(Avp.AGE_OF_LOCATION_ESTIMATE); + if (lcsAgeOfLocEstimateAvp != null) { + try { + return lcsAgeOfLocEstimateAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Age of Location Estimate AVP value", e); + } + } + return -1; + } + + @Override + public boolean isVelocityEstimateAvpPresent() { + return super.message.getAvps().getAvp(Avp.VELOCITY_ESTIMATE) != null; + } + + @Override + public byte[] getVelocityEstimate() { + Avp lcsVelEstimateAvp = super.message.getAvps().getAvp(Avp.VELOCITY_ESTIMATE); + if (lcsVelEstimateAvp != null) { + try { + return lcsVelEstimateAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Velocity Estimate AVP value", e); + } + } + return null; + } + + @Override + public boolean isEUTRANPositioningDataAvpPresent() { + return super.message.getAvps().getAvp(Avp.EUTRAN_POSITIONING_DATA) != null; + } + + @Override + public byte[] getEUTRANPositioningData() { + Avp lcsEUTRANPosDataAvp = super.message.getAvps().getAvp(Avp.EUTRAN_POSITIONING_DATA); + if (lcsEUTRANPosDataAvp != null) { + try { + return lcsEUTRANPosDataAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS E-UTRAN-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isECGIAvpPresent() { + return super.message.getAvps().getAvp(Avp.ECGI) != null; + } + + @Override + public byte[] getECGI() { + Avp lcsECGIAvp = super.message.getAvps().getAvp(Avp.ECGI); + if (lcsECGIAvp != null) { + try { + return lcsECGIAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS ECGI AVP value", e); + } + } + return null; + } + + @Override + public boolean isGERANPositioningInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO) != null; + } + + @Override + public boolean isGERANPositioningDataAvpPresent() { + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + return lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Reporting-Interval AVP", e); + } + } + return false; + } + + @Override + public byte[] getGERANPositioningData() { + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + Avp lcsGERANPositioningDataAvp = lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_POSITIONING_DATA); + if (lcsGERANPositioningDataAvp != null){ + return lcsGERANPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isGERANGANSSPositioningDataAvpPresent() { + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + return lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_GANSS_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GERAN-GANSS-Positioning-Data AVP", e); + } + } + return false; + } + + @Override + public byte[] getGERANGANSSPositioningData() { + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + Avp lcsGERANGANSSPositioningDataAvp = lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_GANSS_POSITIONING_DATA); + if (lcsGERANGANSSPositioningDataAvp != null){ + return lcsGERANGANSSPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-GANSS-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isCellGlobalIdentityAvpPresent() { + return super.message.getAvps().getAvp(Avp.CELL_GLOBAL_IDENTITY) != null; + } + + @Override + public byte[] getCellGlobalIdentity() { + Avp lcsCellGlobalIdAvp = super.message.getAvps().getAvp(Avp.CELL_GLOBAL_IDENTITY); + if (lcsCellGlobalIdAvp != null) { + try { + return lcsCellGlobalIdAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Cell-Global-Identity AVP value", e); + } + } + return null; + } + + @Override + public boolean isUTRANPositioningInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO) != null; + } + + @Override + public boolean isUTRANPositioningDataAvpPresent() { + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + return lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain UTRAN-Positioning-Data AVP", e); + } + } + return false; + } + + @Override + public byte[] getUTRANPositioningData() { + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + Avp lcsUTRANPositioningDataAvp = lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_POSITIONING_DATA); + if (lcsUTRANPositioningDataAvp != null){ + return lcsUTRANPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS UTRAN-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isUTRANGANSSPositioningDataAvpPresent() { + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + return lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_GANSS_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain UTRAN-GANSS-Positioning-Data AVP", e); + } + } + return false; + } + + @Override + public byte[] getUTRANGANSSPositioningData() { + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + Avp lcsUTRANGANSSPositioningDataAvp = lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_GANSS_POSITIONING_DATA); + if (lcsUTRANGANSSPositioningDataAvp != null){ + return lcsUTRANGANSSPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS UTRAN-GANSS-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isServiceAreaIdentityAvpPresent() { + return super.message.getAvps().getAvp(Avp.SERVICE_AREA_IDENTITY) != null; + } + + @Override + public byte[] getServiceAreaIdentity() { + Avp lcsServiceAreaIdentityAvp = super.message.getAvps().getAvp(Avp.SERVICE_AREA_IDENTITY); + if (lcsServiceAreaIdentityAvp != null) { + try { + return lcsServiceAreaIdentityAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SERVICE-AREA-IDENTITY AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSServiceTypeIDAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_SERVICE_TYPE_ID) != null; + } + + @Override + public long getLCSServiceTypeID() { + Avp lcsLCSServiceTypeIDAvp = super.message.getAvps().getAvp(Avp.LCS_SERVICE_TYPE_ID); + if (lcsLCSServiceTypeIDAvp != null) { + try { + return lcsLCSServiceTypeIDAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Service Type ID AVP value", e); + } + } + return -1; + } + + @Override + public boolean isPseudonymIndicatorAvpPresent() { + return super.message.getAvps().getAvp(Avp.PSEUDONYM_INDICATOR) != null; + } + + @Override + public int getPseudonymIndicator() { + Avp lcsPseudonymIndicatorAvp = super.message.getAvps().getAvp(Avp.PSEUDONYM_INDICATOR); + if (lcsPseudonymIndicatorAvp != null) { + try { + return lcsPseudonymIndicatorAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Pseudonym Indicator AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSQoSAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_QOS) != null; + } + + @Override + public boolean isLCSQoSClassAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.LCS_QOS_CLASS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS-Class AVP", e); + } + } + return false; + } + + @Override + public int getLCSQoSClass() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSClassAvp = lcsQoSAvp.getGrouped().getAvp(Avp.LCS_QOS_CLASS); + if (lcsQoSClassAvp != null){ + return lcsQoSClassAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS-Class AVP value", e); + } + } + return -1; + } + + @Override + public boolean isHorizontalAccuracyAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.HORIZONTAL_ACCURACY) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Horizontal-Accuracy AVP", e); + } + } + return false; + } + + @Override + public long getHorizontalAccuracy() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSHorizontalAccuracyAvp = lcsQoSAvp.getGrouped().getAvp(Avp.HORIZONTAL_ACCURACY); + if (lcsQoSHorizontalAccuracyAvp != null){ + return lcsQoSHorizontalAccuracyAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Horizontal-Accuracy AVP value", e); + } + } + return -1; + } + + @Override + public boolean isVerticalAccuracyAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.VERTICAL_ACCURACY) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Accuracy AVP", e); + } + } + return false; + } + + @Override + public long getVerticalAccuracy() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSVerticalAccuracyAvp = lcsQoSAvp.getGrouped().getAvp(Avp.HORIZONTAL_ACCURACY); + if (lcsQoSVerticalAccuracyAvp != null){ + return lcsQoSVerticalAccuracyAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Accuracy AVP value", e); + } + } + return -1; + } + + @Override + public boolean isVerticalRequestedAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.VERTICAL_REQUESTED) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Requested AVP", e); + } + } + return false; + } + + public int getVerticalRequested() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSVerticalRequestedAvp = lcsQoSAvp.getGrouped().getAvp(Avp.VERTICAL_REQUESTED); + if (lcsQoSVerticalRequestedAvp != null){ + return lcsQoSVerticalRequestedAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Requested AVP value", e); + } + } + return -1; + } + + @Override + public boolean isResponseTimeAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.RESPONSE_TIME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Response-Time AVP", e); + } + } + return false; + } + + @Override + public int getResponseTime() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSResponseTimeAvp = lcsQoSAvp.getGrouped().getAvp(Avp.RESPONSE_TIME); + if (lcsQoSResponseTimeAvp != null){ + return lcsQoSResponseTimeAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Response-Time AVP value", e); + } + } + return -1; + } + + @Override + public boolean isServingNodeAvpPresent() { + return super.message.getAvps().getAvp(Avp.SERVING_NODE) != null; + } + + @Override + public boolean isSGSNNumberAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getSGSNNumber() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsSGSNNumberAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER); + if (lcsSGSNNumberAvp != null){ + return lcsSGSNNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isSGSNNameAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Name AVP", e); + } + } + return false; + } + + @Override + public String getSGSNName() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsSGSNNameAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME); + if (lcsSGSNNameAvp != null){ + return lcsSGSNNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isSGSNRealmAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Realm AVP", e); + } + } + return false; + } + + @Override + public String getSGSNRealm() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsSGSNRealmAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM); + if (lcsSGSNRealmAvp != null){ + return lcsSGSNRealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isMMENameAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Name AVP", e); + } + } + return false; + } + + @Override + public String getMMEName() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsMMENameAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_NAME); + if (lcsMMENameAvp != null){ + return lcsMMENameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isMMERealmAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_REALM) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Realm AVP", e); + } + } + return false; + } + + @Override + public String getMMERealm() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsMMERealmAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_REALM); + if (lcsMMERealmAvp != null){ + return lcsMMERealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isMSCNumberAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MSC-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getMSCNumber() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsMSCNumberAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER); + if (lcsMSCNumberAvp != null){ + return lcsMSCNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MSC-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean is3GPPAAAServerNameAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS 3GPP-AAA-Server-Name AVP", e); + } + } + return false; + } + + @Override + public String get3GPPAAAServerName() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcs3GPPAAAServerNameAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME); + if (lcs3GPPAAAServerNameAvp != null){ + return lcs3GPPAAAServerNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS 3GPP-AAA-Server-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSCapabilitiesSetsAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets AVP", e); + } + } + return false; + } + + @Override + public long getLCSCapabilitiesSets() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsCapabilitiesSetsAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS); + if (lcsCapabilitiesSetsAvp != null){ + return lcsCapabilitiesSetsAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets AVP value", e); + } + } + return -1; + } + + @Override + public boolean isGMLCAddressAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GMLC-Address AVP", e); + } + } + return false; + } + + @Override + public java.net.InetAddress getGMLCAddress() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsCapabilitiesSetsAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS); + if (lcsCapabilitiesSetsAvp != null){ + return lcsCapabilitiesSetsAvp.getAddress(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GMLC-Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isLRRFlagsAvpPresent() { + return super.message.getAvps().getAvp(Avp.LRR_FLAGS) != null; + } + + @Override + public long getLRRFLags() { + Avp lcsLRRFlagsAvp = super.message.getAvps().getAvp(Avp.LRR_FLAGS); + if (lcsLRRFlagsAvp != null) { + try { + return lcsLRRFlagsAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS LRR Flags AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSReferenceNumberAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER) != null; + } + + @Override + public byte[] getLCSReferenceNumber() { + Avp lcsLCSReferenceNumberAvp = super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER); + if (lcsLCSReferenceNumberAvp != null) { + try { + return lcsLCSReferenceNumberAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reference Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isDeferredMTLRDataAvpPresent() { + return super.message.getAvps().getAvp(Avp.DEFERRED_MT_LR_DATA) != null; + } + + @Override + public boolean isDeferredLocationTypeAvpPresent() { + Avp lcsDeferredMTLRDataAvp = super.message.getAvps().getAvp(Avp.DEFERRED_MT_LR_DATA); + if (lcsDeferredMTLRDataAvp != null) { + try { + return lcsDeferredMTLRDataAvp.getGrouped().getAvp(Avp.DEFERRED_LOCATION_TYPE) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Deferred-Location-Type AVP", e); + } + } + return false; + } + + @Override + public long getDeferredLocationType() { + Avp lcsDeferredMTLRDataAvp = super.message.getAvps().getAvp(Avp.DEFERRED_MT_LR_DATA); + if (lcsDeferredMTLRDataAvp != null) { + try { + Avp deferredLocationType = lcsDeferredMTLRDataAvp.getGrouped().getAvp(Avp.DEFERRED_LOCATION_TYPE); + if (deferredLocationType != null){ + return deferredLocationType.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Deferred Location Type AVP value", e); + } + } + return -1; + } + + @Override + public boolean isTerminationCauseAvpPresent() { + Avp lcsDeferredMTLRDataAvp = super.message.getAvps().getAvp(Avp.DEFERRED_MT_LR_DATA); + if (lcsDeferredMTLRDataAvp != null) { + try { + return lcsDeferredMTLRDataAvp.getGrouped().getAvp(Avp.TERMINATION_CAUSE_LCS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Termination-Cause AVP", e); + } + } + return false; + } + + @Override + public long getTerminationCause() { + Avp lcsDeferredMTLRDataAvp = super.message.getAvps().getAvp(Avp.DEFERRED_MT_LR_DATA); + if (lcsDeferredMTLRDataAvp != null) { + try { + Avp lcsTerminationCause = lcsDeferredMTLRDataAvp.getGrouped().getAvp(Avp.TERMINATION_CAUSE_LCS); + if (lcsTerminationCause != null){ + return lcsTerminationCause.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Termination-Cause AVP value", e); + } + } + return -1; + } + + @Override + public boolean isHGMLCAddressAvpPresent() { + return super.message.getAvps().getAvp(Avp.GMLC_ADDRESS) != null; // IE: H-GMLC Address mapped to GMLC-Address AVP + } + + @Override + public java.net.InetAddress getHGMLCAddress() { + Avp lcsHGMLCAddressAvp = super.message.getAvps().getAvp(Avp.GMLC_ADDRESS); // IE: H-GMLC Address mapped to GMLC-Address AVP + if (lcsHGMLCAddressAvp != null) { + try { + return lcsHGMLCAddressAvp.getAddress(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain H-GMLC-Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isPeriodicLDRInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION) != null; + } + + @Override + public boolean isReportingAmountAvpPresent() { + Avp lcsPeriodicLDRInfoAvp = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfoAvp != null) { + try { + return lcsPeriodicLDRInfoAvp.getGrouped().getAvp(Avp.REPORTING_AMOUNT) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reporting-Amount AVP", e); + } + } + return false; + } + + @Override + public long getReportingAmount() { + Avp lcsPeriodicLDRInfoAvp = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfoAvp != null) { + try { + Avp lcsReportingAmountAvp = lcsPeriodicLDRInfoAvp.getGrouped().getAvp(Avp.REPORTING_AMOUNT); + if (lcsReportingAmountAvp != null){ + return lcsReportingAmountAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reporting amount AVP value", e); + } + } + return -1; + } + + @Override + public boolean isReportingIntervalAvpPresent() { + Avp lcsPeriodicLDRInfo = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfo != null) { + try { + return lcsPeriodicLDRInfo.getGrouped().getAvp(Avp.REPORTING_INTERVAL) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Reporting-Interval AVP", e); + } + } + return false; + } + + @Override + public long getReportingInterval() { + Avp lcsPeriodicLDRInfo = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfo != null) { + try { + Avp lcsReportingIntervalAvp = lcsPeriodicLDRInfo.getGrouped().getAvp(Avp.REPORTING_INTERVAL); + if (lcsReportingIntervalAvp != null){ + return lcsReportingIntervalAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reporting-Interval AVP value", e); + } + } + return -1; + } + + @Override + public boolean isESMLCCellInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.ESMLC_CELL_INFO) != null; + } + + @Override + public long getCellPortionId() { + Avp lcsCellPortionIdAvp = super.message.getAvps().getAvp(Avp.CELL_PORTION_ID); + if (lcsCellPortionIdAvp != null) { + try { + return lcsCellPortionIdAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Cell-Portion-Id AVP value", e); + } + } + return -1; + } + + @Override + public boolean is1xRTTRCIDAvpPresent() { + return super.message.getAvps().getAvp(Avp.ONEXRTT_RCID) != null; + } + + @Override + public byte[] get1xRTTRCID() { + Avp lcs1xRTTRCIDAvp = super.message.getAvps().getAvp(Avp.ONEXRTT_RCID); + if (lcs1xRTTRCIDAvp != null) { + try { + return lcs1xRTTRCIDAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS 1xRTT_RCID AVP value", e); + } + } + return null; + } + + @Override + public boolean isCivicAddressAvpPresent() { + return super.message.getAvps().getAvp(Avp.CIVIC_ADDRESS) != null; + } + + @Override + public String getCivicAddress() { + Avp lcsCivicAddressAvp = super.message.getAvps().getAvp(Avp.CIVIC_ADDRESS); + if (lcsCivicAddressAvp != null) { + try { + return lcsCivicAddressAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Civic Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isBarometricPressureAvpPresent() { + return super.message.getAvps().getAvp(Avp.BAROMETRIC_PRESSURE) != null; + } + + @Override + public long getBarometricPressure() { + Avp lcsBarometricPressureAvp = super.message.getAvps().getAvp(Avp.BAROMETRIC_PRESSURE); + if (lcsBarometricPressureAvp != null) { + try { + return lcsBarometricPressureAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Barometric Pressure AVP value", e); + } + } + return -1; + } + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java new file mode 100644 index 000000000..e813ca125 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java @@ -0,0 +1,695 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import org.jdiameter.api.Avp; +import org.jdiameter.api.Answer; +import org.jdiameter.api.Request; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public class ProvideLocationAnswerImpl extends AppRequestEventImpl implements ProvideLocationAnswer { + + private static final long serialVersionUID = 1L; + + protected static final Logger logger = LoggerFactory.getLogger(ProvideLocationRequestImpl.class); + + /** + * + * @param answer + */ + public ProvideLocationAnswerImpl(Answer answer) { + super(answer); + } + + /** + * + * @param request + * @param resultCode + */ + public ProvideLocationAnswerImpl(Request request, long resultCode) { + super(request.createAnswer(resultCode)); + } + + public Avp getResultCodeAvp() throws AvpDataException { + return null; + } + + @Override + public boolean isLocationEstimateAvpPresent() { + return super.message.getAvps().getAvp(Avp.LOCATION_ESTIMATE) != null; + } + + @Override + public byte[] getLocationEstimate() { + Avp lcsLocationEstimateAvp = super.message.getAvps().getAvp(Avp.LOCATION_ESTIMATE); + if (lcsLocationEstimateAvp != null) { + try { + return lcsLocationEstimateAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Location-Estimate AVP value", e); + } + } + return null; + } + + @Override + public boolean isAccuracyFulfilmentIndicatorAvpPresent() { + return super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR) != null; + } + + @Override + public int getAccuracyFulfilmentIndicator() { + Avp lcsAccuracyFulfilmentIndAvp = super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR); + if (lcsAccuracyFulfilmentIndAvp != null) { + try { + return lcsAccuracyFulfilmentIndAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Accuracy fulfilment indicator AVP value", e); + } + } + return -1; + } + + @Override + public boolean isAgeOfLocationEstimateAvpPresent() { + return super.message.getAvps().getAvp(Avp.AGE_OF_LOCATION_ESTIMATE) != null; + } + + @Override + public long getAgeOfLocationEstimate() { + Avp lcsAgeOfLocEstimateAvp = super.message.getAvps().getAvp(Avp.AGE_OF_LOCATION_ESTIMATE); + if (lcsAgeOfLocEstimateAvp != null) { + try { + return lcsAgeOfLocEstimateAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Age of Location Estimate AVP value", e); + } + } + return -1; + } + + @Override + public boolean isVelocityEstimateAvpPresent() { + return super.message.getAvps().getAvp(Avp.VELOCITY_ESTIMATE) != null; + } + + @Override + public byte[] getVelocityEstimate() { + Avp lcsVelEstimateAvp = super.message.getAvps().getAvp(Avp.VELOCITY_ESTIMATE); + if (lcsVelEstimateAvp != null) { + try { + return lcsVelEstimateAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Velocity Estimate AVP value", e); + } + } + return null; + } + + @Override + public boolean isEUTRANPositioningDataAvpPresent() { + return super.message.getAvps().getAvp(Avp.EUTRAN_POSITIONING_DATA) != null; + } + + @Override + public byte[] getEUTRANPositioningData() { + Avp lcsEUTRANPosDataAvp = super.message.getAvps().getAvp(Avp.EUTRAN_POSITIONING_DATA); + if (lcsEUTRANPosDataAvp != null) { + try { + return lcsEUTRANPosDataAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS E-UTRAN-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isECGIAvpPresent() { + return super.message.getAvps().getAvp(Avp.ECGI) != null; + } + + @Override + public byte[] getECGI(){ + Avp lcsECGIAvp = super.message.getAvps().getAvp(Avp.ECGI); + if (lcsECGIAvp != null) { + try { + return lcsECGIAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS ECGI AVP value", e); + } + } + return null; + } + + @Override + public boolean isGERANPositioningInfoAvpPresent(){ + return super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO) != null; + } + + @Override + public boolean isGERANPositioningDataAVPPresent(){ + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + return lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Reporting-Interval AVP", e); + } + } + return false; + } + + @Override + public byte[] getGERANPositioningData(){ + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + Avp lcsGERANPositioningDataAvp = lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_POSITIONING_DATA); + if (lcsGERANPositioningDataAvp != null){ + return lcsGERANPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isGERANGANSSPositioningDataAVPPresent() { + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + return lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_GANSS_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GERAN-GANSS-Positioning-Data AVP", e); + } + } + return false; + } + + @Override + public byte[] getGERANGANSSPositioningData() { + Avp lcsGERANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO); + if (lcsGERANPositioningInfoAvp != null) { + try { + Avp lcsGERANGANSSPositioningDataAvp = lcsGERANPositioningInfoAvp.getGrouped().getAvp(Avp.GERAN_GANSS_POSITIONING_DATA); + if (lcsGERANGANSSPositioningDataAvp != null){ + return lcsGERANGANSSPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-GANSS-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isCellGlobalIdentityAvpPresent() { + return super.message.getAvps().getAvp(Avp.CELL_GLOBAL_IDENTITY) != null; + } + + @Override + public byte[] getCellGlobalIdentity() { + Avp lcsCellGlobalIdAvp = super.message.getAvps().getAvp(Avp.CELL_GLOBAL_IDENTITY); + if (lcsCellGlobalIdAvp != null) { + try { + return lcsCellGlobalIdAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Cell-Global-Identity AVP value", e); + } + } + return null; + } + + @Override + public boolean isUTRANPositioningInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO) != null; + } + + @Override + public boolean isUTRANPositioningDataAVPPresent() { + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + return lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain UTRAN-Positioning-Data AVP", e); + } + } + return false; + } + + @Override + public byte[] getUTRANPositioningData() { + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + Avp lcsUTRANPositioningDataAvp = lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_POSITIONING_DATA); + if (lcsUTRANPositioningDataAvp != null){ + return lcsUTRANPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS UTRAN-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isUTRANGANSSPositioningDataAVPPresent(){ + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + return lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_GANSS_POSITIONING_DATA) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain UTRAN-GANSS-Positioning-Data AVP", e); + } + } + return false; + } + + @Override + public byte[] getUTRANGANSSPositioningData(){ + Avp lcsUTRANPositioningInfoAvp = super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO); + if (lcsUTRANPositioningInfoAvp != null) { + try { + Avp lcsUTRANGANSSPositioningDataAvp = lcsUTRANPositioningInfoAvp.getGrouped().getAvp(Avp.UTRAN_GANSS_POSITIONING_DATA); + if (lcsUTRANGANSSPositioningDataAvp != null){ + return lcsUTRANGANSSPositioningDataAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS UTRAN-GANSS-Positioning-Data AVP value", e); + } + } + return null; + } + + @Override + public boolean isServiceAreaIdentityAvpPresent() { + return super.message.getAvps().getAvp(Avp.SERVICE_AREA_IDENTITY) != null; + } + + @Override + public byte[] getServiceAreaIdentity() { + Avp lcsServiceAreaIdentityAvp = super.message.getAvps().getAvp(Avp.SERVICE_AREA_IDENTITY); + if (lcsServiceAreaIdentityAvp != null) { + try { + return lcsServiceAreaIdentityAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SERVICE-AREA-IDENTITY AVP value", e); + } + } + return null; + } + + @Override + public boolean isServingNodeAvpPresent() { + return super.message.getAvps().getAvp(Avp.SERVING_NODE) != null; + } + + @Override + public boolean isSGSNNumberAvpPresent(){ + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getSGSNNumber() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsSGSNNumberAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER); + if (lcsSGSNNumberAvp != null){ + return lcsSGSNNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isSGSNNameAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Name AVP", e); + } + } + return false; + } + + @Override + public String getSGSNName() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsSGSNNameAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME); + if (lcsSGSNNameAvp != null){ + return lcsSGSNNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isSGSNRealmAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Realm AVP", e); + } + } + return false; + } + + @Override + public String getSGSNRealm() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsSGSNRealmAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM); + if (lcsSGSNRealmAvp != null){ + return lcsSGSNRealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SGSN-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isMMENameAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Name AVP", e); + } + } + return false; + } + + @Override + public String getMMEName() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsMMENameAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_NAME); + if (lcsMMENameAvp != null){ + return lcsMMENameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isMMERealmAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_REALM) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Realm AVP", e); + } + } + return false; + } + + @Override + public String getMMERealm() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsMMERealmAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.MME_REALM); + if (lcsMMERealmAvp != null){ + return lcsMMERealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MME-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isMSCNumberAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MSC-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getMSCNumber() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsMSCNumberAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER); + if (lcsMSCNumberAvp != null){ + return lcsMSCNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS MSC-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean is3GPPAAAServerNameAvpPResent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS 3GPP-AAA-Server-Name AVP", e); + } + } + return false; + } + + @Override + public String get3GPPAAAServerName() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcs3GPPAAAServerNameAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME); + if (lcs3GPPAAAServerNameAvp != null){ + return lcs3GPPAAAServerNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS 3GPP-AAA-Server-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSCapabilitiesSetsAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets AVP", e); + } + } + return false; + } + + @Override + public long getLCSCapabilitiesSets() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsCapabilitiesSetsAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS); + if (lcsCapabilitiesSetsAvp != null){ + return lcsCapabilitiesSetsAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets AVP value", e); + } + } + return -1; + } + + @Override + public boolean isGMLCAddressAvpPresent() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + return lcsServingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GMLC-Address AVP", e); + } + } + return false; + } + + @Override + public java.net.InetAddress getGMLCAddress() { + Avp lcsServingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (lcsServingNodeAvp != null) { + try { + Avp lcsCapabilitiesSetsAvp = lcsServingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS); + if (lcsCapabilitiesSetsAvp != null){ + return lcsCapabilitiesSetsAvp.getAddress(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GMLC-Address AVP value", e); + } + } + return null; + } + + + @Override + public boolean isPLAFlagsAvpPresent() { + return super.message.getAvps().getAvp(Avp.PLA_FLAGS) != null; + } + + @Override + public long getPLAFlags(){ + Avp lcsPLAFlagsAvp = super.message.getAvps().getAvp(Avp.PLA_FLAGS); + if (lcsPLAFlagsAvp != null) { + try { + return lcsPLAFlagsAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS PLA-Flags AVP value", e); + } + } + return -1; + } + + @Override + public boolean isESMLCCellInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.ESMLC_CELL_INFO) != null; + } + + @Override + public long getCellPortionId() { + Avp lcsCellPortionIdAvp = super.message.getAvps().getAvp(Avp.CELL_PORTION_ID); + if (lcsCellPortionIdAvp != null) { + try { + return lcsCellPortionIdAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Cell-Portion-Id AVP value", e); + } + } + return -1; + } + + @Override + public boolean isCivicAddressAvpPresent() { + return super.message.getAvps().getAvp(Avp.CIVIC_ADDRESS) != null; + } + + @Override + public String getCivicAddress(){ + Avp lcsCivicAddressAvp = super.message.getAvps().getAvp(Avp.CIVIC_ADDRESS); + if (lcsCivicAddressAvp != null) { + try { + return lcsCivicAddressAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Civic Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isBarometricPressureAvpPresent() { + return super.message.getAvps().getAvp(Avp.BAROMETRIC_PRESSURE) != null; + } + + @Override + public long getBarometricPressure() { + Avp lcsBarometricPressureAvp = super.message.getAvps().getAvp(Avp.BAROMETRIC_PRESSURE); + if (lcsBarometricPressureAvp != null) { + try { + return lcsBarometricPressureAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Barometric Pressure AVP value", e); + } + } + return -1; + } + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationRequestImpl.java new file mode 100644 index 000000000..3c4f3c335 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationRequestImpl.java @@ -0,0 +1,982 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.Message; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ +public class ProvideLocationRequestImpl extends AppRequestEventImpl implements ProvideLocationRequest { + + private static final long serialVersionUID = 1L; + + protected static final Logger logger = LoggerFactory.getLogger(ProvideLocationRequestImpl.class); + + public ProvideLocationRequestImpl(Message message) { + super(message); + message.setRequest(true); + } + + @Override + public boolean isSLgLocationTypeAvpPresent() { + return super.message.getAvps().getAvp(Avp.SLG_LOCATION_TYPE) != null; + } + + @Override + public int getSLgLocationType() { + Avp slgLocationTypeAvp = super.message.getAvps().getAvp(Avp.SLG_LOCATION_TYPE); + if (slgLocationTypeAvp != null) { + try { + return slgLocationTypeAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SLg-Location-Type AVP value", e); + } + } + return -1; + } + + @Override + public boolean isUserNameAvpPresent() { + return super.message.getAvps().getAvp(Avp.USER_NAME) != null; // IE: IMSI + } + + @Override + public String getUserName() { + Avp userNameAvp = super.message.getAvps().getAvp(Avp.USER_NAME); + if (userNameAvp != null) { + try { + return userNameAvp.getUTF8String(); // IE: IMSI mapped to User-Name + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain User-Name AVP value (IMSI)", e); + } + } + return null; + } + + @Override + public boolean isMSISDNAvpPresent() { + return super.message.getAvps().getAvp(Avp.MSISDN) != null; + } + + @Override + public byte[] getMSISDN() { + Avp msisdnAvp = super.message.getAvps().getAvp(Avp.MSISDN); + if (msisdnAvp != null) { + try { + return msisdnAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSISDN AVP value", e); + } + } + return null; + } + + @Override + public boolean isIMEIAvpPresent() { + return super.message.getAvps().getAvp(Avp.TGPP_IMEI) != null; + } + + @Override + public String getIMEI() { + Avp imeiAvp = super.message.getAvps().getAvp(Avp.TGPP_IMEI); + if (imeiAvp != null) { + try { + return imeiAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain IMEI AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSEPSClientNameAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME) != null; + } + + @Override + public boolean isLSCNameStringAvpPresent() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + return lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_NAME_STRING) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Name-String AVP", e); + } + } + return false; + } + + @Override + public String getLSCNameString() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + Avp lcsNameStringAvp = lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_NAME_STRING); + if (lcsNameStringAvp != null){ + return lcsNameStringAvp.getUTF8String(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Name-String AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSFormatIndicatorAvpPresent() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + return lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_FORMAT_INDICATOR) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Format-Indicator AVP", e); + } + } + return false; + } + + @Override + public int getLCSFormatIndicator() { + Avp lcsEPSClientNameAvp = super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME); + if (lcsEPSClientNameAvp != null) { + try { + Avp lcsFormatIndicatorAvp = lcsEPSClientNameAvp.getGrouped().getAvp(Avp.LCS_FORMAT_INDICATOR); + if (lcsFormatIndicatorAvp != null){ + return lcsFormatIndicatorAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Format-Indicator AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSCLientTypeAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_CLIENT_TYPE) != null; + } + + @Override + public int getLCSClientType() { + Avp lcsClientTypeAvp = super.message.getAvps().getAvp(Avp.LCS_CLIENT_TYPE); + if (lcsClientTypeAvp != null) { + try { + return lcsClientTypeAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Client-Type AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSRequestorNamePresent() { + return super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_NAME) != null; + } + + @Override + public boolean isLCSRequestorIdStringAvpPresent() { + Avp lcsRequestorNameAvp = super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_NAME); + if (lcsRequestorNameAvp != null) { + try { + return lcsRequestorNameAvp.getGrouped().getAvp(Avp.LCS_REQUESTOR_ID_STRING) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Requestor-Id-String AVP", e); + } + } + return false; + } + + @Override + public String getLCSRequestorIdString() { + Avp lcsRequestorNameAvp = super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_NAME); + if (lcsRequestorNameAvp != null) { + try { + Avp lcsRequestorIdStringAvp = lcsRequestorNameAvp.getGrouped().getAvp(Avp.LCS_REQUESTOR_ID_STRING); + if (lcsRequestorIdStringAvp != null){ + return lcsRequestorIdStringAvp.getUTF8String(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Requestor-Id-String AVP value", e); + } + } + return null; + } + + @Override + public boolean isReqLCSFormatIndicatorAvpPresent() { + Avp lcsRequestorNameAvp = super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_NAME); + if (lcsRequestorNameAvp != null) { + try { + return lcsRequestorNameAvp.getGrouped().getAvp(Avp.LCS_FORMAT_INDICATOR) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Format-Indicator AVP", e); + } + } + return false; + } + + @Override + public int getReqLCSFormatIndicator() { + Avp lcsRequestorNameAvp = super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_NAME); + if (lcsRequestorNameAvp != null) { + try { + Avp lcsFormatIndicatorAvp = lcsRequestorNameAvp.getGrouped().getAvp(Avp.LCS_FORMAT_INDICATOR); + if (lcsFormatIndicatorAvp != null){ + return lcsFormatIndicatorAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Format-Indicator AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSPriorityPresent() { + return super.message.getAvps().getAvp(Avp.LCS_PRIORITY) != null; + } + + @Override + public long getLCSPriority() { + Avp lcsPriorityAvp = super.message.getAvps().getAvp(Avp.LCS_PRIORITY); + if (lcsPriorityAvp != null) { + try { + return lcsPriorityAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Priority AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSQoSAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_QOS) != null; + } + + @Override + public boolean isLCSQoSClassAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.LCS_QOS_CLASS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS-Class AVP", e); + } + } + return false; + } + + @Override + public int getLCSQoSClass() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSClassAvp = lcsQoSAvp.getGrouped().getAvp(Avp.LCS_QOS_CLASS); + if (lcsQoSClassAvp != null){ + return lcsQoSClassAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS-Class AVP value", e); + } + } + return -1; + } + + @Override + public boolean isHorizontalAccuracyAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.HORIZONTAL_ACCURACY) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Horizontal-Accuracy AVP", e); + } + } + return false; + } + + @Override + public long getHorizontalAccuracy() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSHorizontalAccuracyAvp = lcsQoSAvp.getGrouped().getAvp(Avp.HORIZONTAL_ACCURACY); + if (lcsQoSHorizontalAccuracyAvp != null){ + return lcsQoSHorizontalAccuracyAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Horizontal-Accuracy AVP value", e); + } + } + return -1; + } + + @Override + public boolean isVerticalAccuracyAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.VERTICAL_ACCURACY) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Accuracy AVP", e); + } + } + return false; + } + + @Override + public long getVerticalAccuracy() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSVerticalAccuracyAvp = lcsQoSAvp.getGrouped().getAvp(Avp.VERTICAL_ACCURACY); + if (lcsQoSVerticalAccuracyAvp != null){ + return lcsQoSVerticalAccuracyAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Accuracy AVP value", e); + } + } + return -1; + } + + @Override + public boolean isVerticalRequestedAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.VERTICAL_REQUESTED) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Requested AVP", e); + } + } + return false; + } + + public int getVerticalRequested() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSVerticalRequestedAvp = lcsQoSAvp.getGrouped().getAvp(Avp.VERTICAL_REQUESTED); + if (lcsQoSVerticalRequestedAvp != null){ + return lcsQoSVerticalRequestedAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Vertical-Requested AVP value", e); + } + } + return -1; + } + + @Override + public boolean isResponseTimeAvpPresent() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + return lcsQoSAvp.getGrouped().getAvp(Avp.RESPONSE_TIME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Response-Time AVP", e); + } + } + return false; + } + + @Override + public int getResponseTime() { + Avp lcsQoSAvp = super.message.getAvps().getAvp(Avp.LCS_QOS); + if (lcsQoSAvp != null) { + try { + Avp lcsQoSResponseTimeAvp = lcsQoSAvp.getGrouped().getAvp(Avp.RESPONSE_TIME); + if (lcsQoSResponseTimeAvp != null){ + return lcsQoSResponseTimeAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Response-Time AVP value", e); + } + } + return -1; + } + + @Override + public boolean isVelocityRequestedAvpPresent() { + return super.message.getAvps().getAvp(Avp.VELOCITY_REQUESTED) != null; + } + + @Override + public int getVelocityRequested() { + Avp lcsVelocityRequestedAvp = super.message.getAvps().getAvp(Avp.VELOCITY_REQUESTED); + if (lcsVelocityRequestedAvp != null) { + try { + return lcsVelocityRequestedAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Velocity-Requested AVP value", e); + } + } + return-1; + } + + @Override + public boolean isSupportedGADShapesAvpPresent() { + return super.message.getAvps().getAvp(Avp.SUPPORTED_GAD_SHAPES) != null; + } + + @Override + public long getSupportedGADSahpes() { + Avp lcsSupportedGADShapesAvp = super.message.getAvps().getAvp(Avp.SUPPORTED_GAD_SHAPES); + if (lcsSupportedGADShapesAvp != null) { + try { + return lcsSupportedGADShapesAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Supported GAD Shapes AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLSCServiceTypeIdAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_SERVICE_TYPE_ID) != null; + } + + @Override + public long getLSCServiceTypeId() { + Avp lcsServiceTypeIdAvp = super.message.getAvps().getAvp(Avp.LCS_SERVICE_TYPE_ID); + if (lcsServiceTypeIdAvp != null) { + try { + return lcsServiceTypeIdAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Service Type ID AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSCodewordAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_CODEWORD) != null; + } + + @Override + public String getLCSCodeword() { + Avp lcsCodewordAvp = super.message.getAvps().getAvp(Avp.LCS_CODEWORD); + if (lcsCodewordAvp != null) { + try { + return lcsCodewordAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Codeword AVP value", e); + } + } + return null; + } + + @Override + public boolean isServiceSelectionAvpPresent() { + return super.message.getAvps().getAvp(Avp.SERVICE_SELECTION) != null; + } + + @Override + public String getServiceSelection() { + Avp lcsServiceSelectionAvp = super.message.getAvps().getAvp(Avp.SERVICE_SELECTION); + if (lcsServiceSelectionAvp != null) { + try { + return lcsServiceSelectionAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Service Selection AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSPrivacyCheckSessionAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_SESSION) != null; + } + + @Override + public boolean isLCSPrivacyCheckAvpPresent() { + Avp lcPrivacyCheckSessionAvp = super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_SESSION); + if (lcPrivacyCheckSessionAvp != null) { + try { + return lcPrivacyCheckSessionAvp.getGrouped().getAvp(Avp.LCS_PRIVACY_CHECK) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Privacy-Check AVP", e); + } + } + return false; + } + + @Override + public int getLCSPrivacyCheck() { + Avp lcPrivacyCheckSessionAvp = super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_SESSION); + if (lcPrivacyCheckSessionAvp != null) { + try { + Avp lcsPrivacyCheckAvp = lcPrivacyCheckSessionAvp.getGrouped().getAvp(Avp.LCS_PRIVACY_CHECK); + if (lcsPrivacyCheckAvp != null){ + return lcsPrivacyCheckAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Privacy-Check AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSPrivacyCheckNonSessionAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_NON_SESSION) != null; + } + + @Override + public boolean isLCSPrivacyCheckNSAvpPresent() { + Avp lcPrivacyCheckNonSessionAvp = super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_NON_SESSION); + if (lcPrivacyCheckNonSessionAvp != null) { + try { + return lcPrivacyCheckNonSessionAvp.getGrouped().getAvp(Avp.LCS_PRIVACY_CHECK) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Privacy-Check AVP", e); + } + } + return false; + } + + @Override + public int getLCSPrivacyCheckNS() { + Avp lcPrivacyCheckNonSessionAvp = super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_NON_SESSION); + if (lcPrivacyCheckNonSessionAvp != null) { + try { + Avp lcsPrivacyCheckAvp = lcPrivacyCheckNonSessionAvp.getGrouped().getAvp(Avp.LCS_PRIVACY_CHECK); + if (lcsPrivacyCheckAvp != null){ + return lcsPrivacyCheckAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Privacy-Check AVP value", e); + } + } + return -1; + } + + @Override + public boolean isDeferredLocationTypeAvpPresent() { + return super.message.getAvps().getAvp(Avp.DEFERRED_LOCATION_TYPE) != null; + } + + @Override + public long getDeferredLocationType() { + Avp lcsDeferredLocationTypeAvp = super.message.getAvps().getAvp(Avp.DEFERRED_LOCATION_TYPE); + if (lcsDeferredLocationTypeAvp != null) { + try { + return lcsDeferredLocationTypeAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Deferred Location Type AVP value", e); + } + } + return -1; + } + + @Override + public boolean isLCSReferenceNumberAvpPresent() { + return super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER) != null; + } + + @Override + public byte[] getLCSReferenceNumber() { + Avp lcsLCSReferenceNumberAvp = super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER); + if (lcsLCSReferenceNumberAvp != null) { + try { + return lcsLCSReferenceNumberAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reference Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isAreaEventInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.AREA_EVENT_INFO) != null; + } + + @Override + public boolean isOccurrenceInfoAvpPresent() { + Avp lcsAreaEventInfoAvp = super.message.getAvps().getAvp(Avp.AREA_EVENT_INFO); + if (lcsAreaEventInfoAvp != null) { + try { + return lcsAreaEventInfoAvp.getGrouped().getAvp(Avp.OCCURRENCE_INFO) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Ocurrence-Info AVP", e); + } + } + return false; + } + + @Override + public int getOccurrenceInfo() { + Avp lcsAreaEventInfoAvp = super.message.getAvps().getAvp(Avp.AREA_EVENT_INFO); + if (lcsAreaEventInfoAvp != null) { + try { + Avp lcsOccurrenceInfoAvp = lcsAreaEventInfoAvp.getGrouped().getAvp(Avp.OCCURRENCE_INFO); + if (lcsOccurrenceInfoAvp != null){ + return lcsOccurrenceInfoAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Ocurrence-Info AVP value", e); + } + } + return -1; + } + + @Override + public boolean isIntervalTimeAvpPresent() { + Avp lcsAreaEventInfoAvp = super.message.getAvps().getAvp(Avp.AREA_EVENT_INFO); + if (lcsAreaEventInfoAvp != null) { + try { + return lcsAreaEventInfoAvp.getGrouped().getAvp(Avp.INTERVAL_TIME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Interval-Time AVP", e); + } + } + return false; + } + + @Override + public long getIntervalTime() { + Avp lcsAreaEventInfoAvp = super.message.getAvps().getAvp(Avp.AREA_EVENT_INFO); + if (lcsAreaEventInfoAvp != null) { + try { + Avp lcsIntervalTimeAvp = lcsAreaEventInfoAvp.getGrouped().getAvp(Avp.INTERVAL_TIME); + if (lcsIntervalTimeAvp != null){ + return lcsIntervalTimeAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Interval-Time AVP value", e); + } + } + return -1; + } + + @Override + public boolean isAreaDefinitionAvpPresent() { + Avp lcsAreaEventInfoAvp = super.message.getAvps().getAvp(Avp.AREA_EVENT_INFO); + if (lcsAreaEventInfoAvp != null) { + try { + return lcsAreaEventInfoAvp.getGrouped().getAvp(Avp.AREA_DEFINITION) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Area-Definition AVP", e); + } + } + return false; + } + + @Override + public boolean isAreaTypeAvpPresent() { + Avp lcsAreaDefinitionAvp = super.message.getAvps().getAvp(Avp.AREA_DEFINITION); + if (lcsAreaDefinitionAvp != null) { + try { + return lcsAreaDefinitionAvp.getGrouped().getAvp(Avp.AREA_TYPE) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Area-Type AVP", e); + } + } + return false; + } + + @Override + public long getAreaType() { + Avp lcsAreaDefinitionAvp = super.message.getAvps().getAvp(Avp.AREA_DEFINITION); + if (lcsAreaDefinitionAvp != null) { + try { + Avp lcsAreaTypeAvp = lcsAreaDefinitionAvp.getGrouped().getAvp(Avp.AREA_TYPE); + if (lcsAreaTypeAvp != null){ + return lcsAreaTypeAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Area-Type AVP value", e); + } + } + return -1; + } + + @Override + public boolean isAreaIdentificationAvpPresent() { + Avp lcsAreaDefinitionAvp = super.message.getAvps().getAvp(Avp.AREA_DEFINITION); + if (lcsAreaDefinitionAvp != null) { + try { + return lcsAreaDefinitionAvp.getGrouped().getAvp(Avp.AREA_IDENTIFICATION) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Area-Identification AVP", e); + } + } + return false; + } + + @Override + public byte[] getAreaIdentification() { + Avp lcsAreaDefinitionAvp = super.message.getAvps().getAvp(Avp.AREA_DEFINITION); + if (lcsAreaDefinitionAvp != null) { + try { + Avp lcsAreaIdAvp = lcsAreaDefinitionAvp.getGrouped().getAvp(Avp.AREA_DEFINITION); + if (lcsAreaIdAvp != null){ + return lcsAreaIdAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Area Identification AVP value", e); + } + } + return null; + } + + @Override + public boolean isGMLCAddressAvpPresent() { + return super.message.getAvps().getAvp(Avp.GMLC_ADDRESS) != null; + } + + @Override + public java.net.InetAddress getGMLCAddress() { + Avp lcsGMLCAddressAvp = super.message.getAvps().getAvp(Avp.GMLC_ADDRESS); + if (lcsGMLCAddressAvp != null) { + try { + return lcsGMLCAddressAvp.getAddress(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isPLRFlagsAvpPresent() { + return super.message.getAvps().getAvp(Avp.PLR_FLAGS) != null; + } + + @Override + public long getPLRFLags() { + Avp lcsPLRFlagsAvp = super.message.getAvps().getAvp(Avp.PLR_FLAGS); + if (lcsPLRFlagsAvp != null) { + try { + return lcsPLRFlagsAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS PLR Flags AVP value", e); + } + } + return -1; + } + + @Override + public boolean isPeriodicLDRInfoAvpPresent() { + return super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION) != null; + } + + @Override + public boolean isReportingAmountAvpPresent() { + Avp lcsPeriodicLDRInfo = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfo != null) { + try { + return lcsPeriodicLDRInfo.getGrouped().getAvp(Avp.REPORTING_AMOUNT) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Reporting-Amount AVP", e); + } + } + return false; + } + + @Override + public long getReportingAmount() { + Avp lcsPeriodicLDRInfo = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfo != null) { + try { + Avp lcsReportingAmountAvp = lcsPeriodicLDRInfo.getGrouped().getAvp(Avp.REPORTING_AMOUNT); + if (lcsReportingAmountAvp != null){ + return lcsReportingAmountAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reporting amount AVP value", e); + } + } + return -1; + } + + @Override + public boolean isReportingIntervalAvpPresent() { + Avp lcsPeriodicLDRInfo = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfo != null) { + try { + return lcsPeriodicLDRInfo.getGrouped().getAvp(Avp.REPORTING_INTERVAL) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Reporting-Interval AVP", e); + } + } + return false; + } + + @Override + public long getReportingInterval() { + Avp lcsPeriodicLDRInfo = super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION); + if (lcsPeriodicLDRInfo != null) { + try { + Avp lcsReportingIntervalAvp = lcsPeriodicLDRInfo.getGrouped().getAvp(Avp.REPORTING_INTERVAL); + if (lcsReportingIntervalAvp != null){ + return lcsReportingIntervalAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reporting-Interval AVP value", e); + } + } + return -1; + } + + @Override + public boolean isReportingPLMNListAvpPresent() { + return super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST) != null; + } + + @Override + public boolean isPrioritizedListIndicatorAvpPresent() { + Avp lcsReportingPLMNListAvp = super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST); + if (lcsReportingPLMNListAvp != null) { + try { + return lcsReportingPLMNListAvp.getGrouped().getAvp(Avp.PRIORITIZED_LIST_INDICATOR) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Prioritized-List-Indicator AVP", e); + } + } + return false; + } + + @Override + public int getPrioritizedListIndicator() { + Avp lcsReportingPLMNListAvp = super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST); + if (lcsReportingPLMNListAvp != null) { + try { + Avp lcsPrioritizedListIndicatorAvp = lcsReportingPLMNListAvp.getGrouped().getAvp(Avp.PRIORITIZED_LIST_INDICATOR); + if (lcsPrioritizedListIndicatorAvp != null){ + return lcsPrioritizedListIndicatorAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-Positioning-Data AVP value", e); + } + } + return -1; + } + + @Override + public boolean isPLMNIDListAvpPresent() { + Avp lcsReportingPLMNListAvp = super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST); + if (lcsReportingPLMNListAvp != null) { + try { + return lcsReportingPLMNListAvp.getGrouped().getAvp(Avp.PLMN_ID_LIST) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain PLMN-Id-List AVP", e); + } + } + return false; + } + + @Override + public boolean isVisitedPLMNIdAvpPresent() { + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + return lcsPLMNIdListAvp.getGrouped().getAvp(Avp.VISITED_PLMN_ID) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Visited-PLMN-Id AVP", e); + } + } + return false; + } + + @Override + public byte[] getVisitedPLMNId() { + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + Avp lcsVisitedPLMNIdAvp = lcsPLMNIdListAvp.getGrouped().getAvp(Avp.VISITED_PLMN_ID); + if (lcsVisitedPLMNIdAvp != null){ + return lcsVisitedPLMNIdAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Visited PLMN ID AVP value", e); + } + } + return null; + } + + @Override + public boolean isPeriodicLocationSupportIndicatorAvpPresent() { + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + return lcsPLMNIdListAvp.getGrouped().getAvp(Avp.PERIODIC_LOCATION_SUPPORT_INDICATOR) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain Periodic-Location-Support-Indicator AVP", e); + } + } + return false; + } + + @Override + public int getPeriodicLocationSupportIndicator() { + Avp lcsPLMNIdListAvp = super.message.getAvps().getAvp(Avp.PLMN_ID_LIST); + if (lcsPLMNIdListAvp != null) { + try { + Avp lcsPeriodicLocationSupportIndicatorAvp = lcsPLMNIdListAvp.getGrouped().getAvp(Avp.PERIODIC_LOCATION_SUPPORT_INDICATOR); + if (lcsPeriodicLocationSupportIndicatorAvp != null){ + return lcsPeriodicLocationSupportIndicatorAvp.getInteger32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Periodic Location Support Indicator AVP value", e); + } + } + return -1; + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataFactory.java new file mode 100644 index 000000000..668019f62 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataFactory.java @@ -0,0 +1,73 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.client.impl.app.slg.ClientSLgSessionDataLocalImpl; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.jdiameter.server.impl.app.slg.ServerSLgSessionDataLocalImpl; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLgLocalSessionDataFactory implements IAppSessionDataFactory { + + public ISLgSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLgSession.class)) { + ClientSLgSessionDataLocalImpl data = new ClientSLgSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else if (clazz.equals(ServerSLgSession.class)) { + ServerSLgSessionDataLocalImpl data = new ServerSLgSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else { + throw new IllegalArgumentException("Invalid Session Class: " + clazz.toString()); + } + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataImpl.java new file mode 100644 index 000000000..1f0547657 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataImpl.java @@ -0,0 +1,86 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import java.io.Serializable; + +import org.jdiameter.api.Request; +import org.jdiameter.common.api.app.AppSessionDataLocalImpl; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.jdiameter.common.api.app.slg.SLgSessionState; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLgLocalSessionDataImpl extends AppSessionDataLocalImpl implements ISLgSessionData { + + protected SLgSessionState state = SLgSessionState.IDLE; + protected Request buffer; + protected Serializable tsTimerId; + + public void setSLgSessionState(SLgSessionState state) { + this.state = state; + } + + public SLgSessionState getSLgSessionState() { + return this.state; + } + + public Serializable getTsTimerId() { + return this.tsTimerId; + } + + public void setTsTimerId(Serializable tid) { + this.tsTimerId = tid; + } + + public void setBuffer(Request buffer) { + this.buffer = buffer; + } + + public Request getBuffer() { + return this.buffer; + } +} \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSession.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSession.java new file mode 100644 index 000000000..20e2005cc --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSession.java @@ -0,0 +1,155 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import java.io.Serializable; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.app.StateMachine; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.AppSessionImpl; +import org.jdiameter.common.api.app.slg.ISLgMessageFactory; +import org.jdiameter.common.api.app.slg.ISLgSessionData; + +/** + * @author Fernando Mendioroz + * + */ + +public abstract class SLgSession extends AppSessionImpl implements NetworkReqListener, StateMachine { + + public static final int _TX_TIMEOUT = 30 * 1000; + + protected Lock sendAndStateLock = new ReentrantLock(); + + @SuppressWarnings("rawtypes") + protected transient List stateListeners = new CopyOnWriteArrayList(); + protected transient ISLgMessageFactory messageFactory; + + protected static final String TIMER_NAME_MSG_TIMEOUT = "MSG_TIMEOUT"; + protected ISLgSessionData sessionData; + + public SLgSession(ISessionFactory sf, ISLgSessionData sessionData) { + super(sf, sessionData); + this.sessionData = sessionData; + } + + @SuppressWarnings("rawtypes") + public void addStateChangeNotification(StateChangeListener listener) { + if (!stateListeners.contains(listener)) { + stateListeners.add(listener); + } + } + + @SuppressWarnings("rawtypes") + public void removeStateChangeNotification(StateChangeListener listener) { + stateListeners.remove(listener); + } + + public boolean isStateless() { + return true; + } + + @Override + public boolean isReplicable() { + return false; + } + + protected void startMsgTimer() { + try { + sendAndStateLock.lock(); + sessionData.setTsTimerId(super.timerFacility.schedule(getSessionId(), TIMER_NAME_MSG_TIMEOUT, _TX_TIMEOUT)); + } finally { + sendAndStateLock.unlock(); + } + } + + protected void cancelMsgTimer() { + try { + sendAndStateLock.lock(); + final Serializable timerId = this.sessionData.getTsTimerId(); + if (timerId == null) { + return; + } + super.timerFacility.cancel(timerId); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((sessionData == null) ? 0 : sessionData.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + SLgSession other = (SLgSession) obj; + if (sessionData == null) { + if (other.sessionData != null) { + return false; + } + } else if (!sessionData.equals(other.sessionData)) { + return false; + } + return true; + } +} \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java new file mode 100644 index 000000000..e53ceaaae --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java @@ -0,0 +1,312 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slg; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.SessionFactory; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ClientSLgSessionListener; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.ServerSLgSessionListener; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.client.impl.app.slg.IClientSLgSessionData; +import org.jdiameter.client.impl.app.slg.SLgClientSessionImpl; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slg.ISLgMessageFactory; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.jdiameter.common.api.app.slg.ISLgSessionFactory; +import org.jdiameter.common.api.data.ISessionDatasource; +import org.jdiameter.server.impl.app.slg.IServerSLgSessionData; +import org.jdiameter.server.impl.app.slg.SLgServerSessionImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLgSessionFactoryImpl implements ISLgSessionFactory, ServerSLgSessionListener, ClientSLgSessionListener, + ISLgMessageFactory, StateChangeListener { + + private static final Logger logger = LoggerFactory.getLogger(SLgSessionFactoryImpl.class); + + protected ISessionFactory sessionFactory; + + protected ServerSLgSessionListener serverSessionListener; + protected ClientSLgSessionListener clientSessionListener; + + protected ISLgMessageFactory messageFactory; + protected StateChangeListener stateListener; + protected ISessionDatasource iss; + protected IAppSessionDataFactory sessionDataFactory; + + public SLgSessionFactoryImpl() { + }; + + public SLgSessionFactoryImpl(SessionFactory sessionFactory) { + super(); + init(sessionFactory); + } + + public void init(SessionFactory sessionFactory) { + this.sessionFactory = (ISessionFactory) sessionFactory; + this.iss = this.sessionFactory.getContainer().getAssemblerFacility().getComponentInstance(ISessionDatasource.class); + this.sessionDataFactory = (IAppSessionDataFactory) this.iss.getDataFactory(ISLgSessionData.class); + } + + /** + * @return the serverSessionListener + */ + public ServerSLgSessionListener getServerSessionListener() { + return serverSessionListener != null ? serverSessionListener : this; + } + + /** + * @param serverSessionListener the serverSessionListener to set + */ + public void setServerSessionListener(ServerSLgSessionListener serverSessionListener) { + this.serverSessionListener = serverSessionListener; + } + + /** + * @return the serverSessionListener + */ + public ClientSLgSessionListener getClientSessionListener() { + return clientSessionListener != null ? clientSessionListener : this; + } + + /** + * @param clientSessionListener theclientSessionListener to set + */ + public void setClientSessionListener(ClientSLgSessionListener clientSessionListener) { + this.clientSessionListener = clientSessionListener; + } + + /** + * @return the messageFactory + */ + public ISLgMessageFactory getMessageFactory() { + return messageFactory != null ? messageFactory : this; + } + + /** + * @param messageFactory the messageFactory to set + */ + public void setMessageFactory(ISLgMessageFactory messageFactory) { + this.messageFactory = messageFactory; + } + + /** + * @return the stateListener + */ + public StateChangeListener getStateListener() { + return stateListener != null ? stateListener : this; + } + + /** + * @param stateListener the stateListener to set + */ + public void setStateListener(StateChangeListener stateListener) { + this.stateListener = stateListener; + } + + public AppSession getSession(String sessionId, Class aClass) { + if (sessionId == null) { + throw new IllegalArgumentException("SessionId must not be null"); + } + if (!this.iss.exists(sessionId)) { + return null; + } + AppSession appSession = null; + try { + if (aClass == ServerSLgSession.class) { + IServerSLgSessionData sessionData = (IServerSLgSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLgSession.class, sessionId); + SLgServerSessionImpl serverSession = new SLgServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLgSession.class) { + IClientSLgSessionData sessionData = (IClientSLgSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLgSession.class, sessionId); + SLgClientSessionImpl clientSession = new SLgClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLgSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLg Session.", e); + } + return appSession; + } + + public AppSession getNewSession(String sessionId, Class aClass, ApplicationId applicationId, + Object[] args) { + AppSession appSession = null; + + try { + if (aClass == ServerSLgSession.class) { + if (sessionId == null) { + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } + } + IServerSLgSessionData sessionData = (IServerSLgSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLgSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLgServerSessionImpl serverSession = new SLgServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + + iss.addSession(serverSession); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLgSession.class) { + if (sessionId == null) { + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } + } + IClientSLgSessionData sessionData = (IClientSLgSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLgSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLgClientSessionImpl clientSession = new SLgClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + + iss.addSession(clientSession); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLgSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLg Session.", e); + } + return appSession; + } + + public void stateChanged(Enum oldState, Enum newState) { + logger.info("Diameter SLg Session Factory :: stateChanged :: oldState[{}], newState[{}]", oldState, newState); + } + + public long getApplicationId() { + return 16777255; + } + + public void stateChanged(AppSession source, Enum oldState, Enum newState) { + logger.info("Diameter SLg Session Factory :: stateChanged :: Session, [{}], oldState[{}], newState[{}]", + new Object[] { source, oldState, newState }); + } + + public ProvideLocationRequest createProvideLocationRequest(Request request) { + return new ProvideLocationRequestImpl(request); + } + + public ProvideLocationAnswer createProvideLocationAnswer(Answer answer) { + return new ProvideLocationAnswerImpl(answer); + } + + public void doProvideLocationRequestEvent(ServerSLgSession appSession, ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doProvideLocationRequestEvent :: appSession[{}], Request[{}]", appSession, + request); + } + + public void doProvideLocationAnswerEvent(ClientSLgSession appSession, ProvideLocationRequest request, + ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doProvideLocationAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } + + public LocationReportRequest createLocationReportRequest(Request request) { + return new LocationReportRequestImpl(request); + } + + public LocationReportAnswer createLocationReportAnswer(Answer answer) { + return new LocationReportAnswerImpl(answer); + } + + public void doLocationReportRequestEvent(ServerSLgSession appSession, LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doLocationReportRequestEvent :: appSession[{}], Request[{}]", appSession, + request); + } + + public void doLocationReportAnswerEvent(ClientSLgSession appSession, LocationReportRequest request, + LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doLocationReportAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } + + public void doOtherEvent(AppSession appSession, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doOtherEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java new file mode 100644 index 000000000..21a4b4196 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java @@ -0,0 +1,708 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slh; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.Request; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +// import java.net.InetAddress; + +/** + * @author Fernando Mendioroz + * + */ +public class LCSRoutingInfoAnswerImpl extends AppRequestEventImpl implements LCSRoutingInfoAnswer { + + private static final long serialVersionUID = 1L; + + protected static final Logger logger = LoggerFactory.getLogger(LCSRoutingInfoAnswer.class); + + /** + * + * @param answer + */ + public LCSRoutingInfoAnswerImpl(Answer answer) { + super(answer); + } + + /** + * + * @param request + * @param resultCode + */ + public LCSRoutingInfoAnswerImpl(Request request, long resultCode) { + super(request.createAnswer(resultCode)); + } + + @Override + public boolean isUserNameAVPPresent() { + return super.message.getAvps().getAvp(Avp.USER_NAME) != null; // IE: IMSI mapped to User-Name AVP + } + + @Override + public String getUserName() { + Avp userNameAvp = super.message.getAvps().getAvp(Avp.USER_NAME); + if (userNameAvp != null) { + try { + return userNameAvp.getUTF8String(); // IE: IMSI mapped to User-Name AVP + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain User-Name AVP value (IMSI)", e); + } + } + return null; + } + + @Override + public boolean isMSISDNAVPPresent() { + return super.message.getAvps().getAvp(Avp.MSISDN) != null; + } + + @Override + public byte[] getMSISDN() { + Avp msisdnAvp = super.message.getAvps().getAvp(Avp.MSISDN); + if (msisdnAvp != null) { + try { + return msisdnAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSISDN AVP value", e); + } + } + return null; + } + + @Override + public boolean isLMSIAVPPresent() { + return super.message.getAvps().getAvp(Avp.LMSI) != null; + } + + @Override + public byte[] getLMSI() { + Avp localMobileStationIdentityAvp = super.message.getAvps().getAvp(Avp.LMSI); + if (localMobileStationIdentityAvp != null) { + try { + return localMobileStationIdentityAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LMSI AVP value", e); + } + } + return null; + } + + @Override + public boolean isServingNodeAVPPresent() { + return super.message.getAvps().getAvp(Avp.SERVING_NODE) != null; + } + + @Override + public boolean isSGSNNumberAVPPresent() { + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getSGSNNumber(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp sgsnNumberAvp = servingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER); + if (sgsnNumberAvp != null){ + return sgsnNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isSGSNNameAVPPresent() { + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Name AVP", e); + } + } + return false; + } + + @Override + public String getSGSNName(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp sgsnNameAvp = servingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME); + if (sgsnNameAvp != null){ + return sgsnNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isSGSNRealmAVPPresent() { + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Realm AVP", e); + } + } + return false; + } + + @Override + public String getSGSNRealm(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp sgsnRealmAvp = servingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM); + if (sgsnRealmAvp != null){ + return sgsnRealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isMMENameAVPPresent() { + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.MME_NAME) != null; + } catch (AvpDataException ex) { + logger.debug("Failure trying to obtain MME-Name AVP", ex); + } + } + return false; + } + + @Override + public String getMMEName(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp mmeNameAvp = servingNodeAvp.getGrouped().getAvp(Avp.MME_NAME); + if (mmeNameAvp != null){ + return mmeNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MME-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isMMERealmAVPPresent() { + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.MME_REALM) != null; + } catch (AvpDataException ex) { + logger.debug("Failure trying to obtain MME-Realm AVP", ex); + } + } + return false; + } + + @Override + public String getMMERealm(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp mmeRealmAvp = servingNodeAvp.getGrouped().getAvp(Avp.MME_REALM); + if (mmeRealmAvp != null){ + return mmeRealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MME-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isMSCNumberAVPPresent() { + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSC-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getMSCNumber(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp mscNumberAvp = servingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER); + if (mscNumberAvp != null){ + return mscNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSC-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean is3GPPAAAServerNameAVPPresent() { + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain 3GPP-AAA-Server-Name AVP", e); + } + } + return false; + } + + @Override + public String get3GPPAAAServerName(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp tgppAAAServerNameAvp = servingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME); + if (tgppAAAServerNameAvp != null){ + return tgppAAAServerNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSC-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isLCSCapabilitiesSetsAVPPresent(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets AVP", e); + } + } + return false; + } + + @Override + public long getLCSCapabilitiesSets(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp lcsCapabilitiesSetsAvp = servingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS); + if (lcsCapabilitiesSetsAvp != null){ + return lcsCapabilitiesSetsAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets value", e); + } + } + return -1; + } + + @Override + public boolean isGMLCAddressAVPPresent(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + return servingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC-Address AVP", e); + } + } + return false; + } + + @Override + public java.net.InetAddress getGMLCAddress(){ + Avp servingNodeAvp = super.message.getAvps().getAvp(Avp.SERVING_NODE); + if (servingNodeAvp != null) { + try { + Avp gmlcAddressAvp = servingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS); + if (gmlcAddressAvp != null){ + return gmlcAddressAvp.getAddress(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC-Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditionalServingNodeAVPPresent(){ + return super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE) != null; + } + + @Override + public boolean isAdditionalSGSNNumberAVPPresent() { + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getAdditionalSGSNNumber(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp sgsnNumberAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NUMBER); + if (sgsnNumberAvp != null){ + return sgsnNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditionalSGSNNameAVPPresent() { + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Name AVP", e); + } + } + return false; + } + + @Override + public String getAdditionalSGSNName(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp sgsnNameAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.SGSN_NAME); + if (sgsnNameAvp != null){ + return sgsnNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditionalSGSNRealmAVPPresent() { + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Realm AVP", e); + } + } + return false; + } + + @Override + public String getAdditionalSGSNRealm(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp sgsnRealmAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.SGSN_REALM); + if (sgsnRealmAvp != null){ + return sgsnRealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain SGSN-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditionalMMENameAVPPresent() { + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.MME_NAME) != null; + } catch (AvpDataException ex) { + logger.debug("Failure trying to obtain MME-Name AVP", ex); + } + } + return false; + } + + @Override + public String getAdditionalMMEName(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp mmeNameAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.MME_NAME); + if (mmeNameAvp != null){ + return mmeNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MME-Name AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditionalMMERealmAVPPresent() { + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.MME_REALM) != null; + } catch (AvpDataException ex) { + logger.debug("Failure trying to obtain MME-Realm AVP", ex); + } + } + return false; + } + + @Override + public String getAdditionalMMERealm(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp mmeRealmAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.MME_REALM); + if (mmeRealmAvp != null){ + return mmeRealmAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MME-Realm AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditionalMSCNumberAVPPresent() { + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSC-Number AVP", e); + } + } + return false; + } + + @Override + public byte[] getAdditionalMSCNumber(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp mscNumberAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.MSC_NUMBER); + if (mscNumberAvp != null){ + return mscNumberAvp.getOctetString(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSC-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditional3GPPAAAServerNameAVPPresent() { + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain 3GPP-AAA-Server-Name AVP", e); + } + } + return false; + } + + @Override + public String getAdditional3GPPAAAServerName(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp tgppAAAServerNameAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.TGPP_AAA_SERVER_NAME); + if (tgppAAAServerNameAvp != null){ + return tgppAAAServerNameAvp.getDiameterIdentity(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSC-Number AVP value", e); + } + } + return null; + } + + @Override + public boolean isAdditionalLCSCapabilitiesSetsAVPPresent(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets AVP", e); + } + } + return false; + } + + @Override + public long getAdditionalLCSCapabilitiesSets(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp lcsCapabilitiesSetsAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.LCS_CAPABILITIES_SETS); + if (lcsCapabilitiesSetsAvp != null){ + return lcsCapabilitiesSetsAvp.getUnsigned32(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Capabilities-Sets value", e); + } + } + return -1; + } + + @Override + public boolean isAdditionalGMLCAddressAVPPresent(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + return additionalServingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS) != null; + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC-Address AVP", e); + } + } + return false; + } + + @Override + public java.net.InetAddress getAdditionalGMLCAddress(){ + Avp additionalServingNodeAvp = super.message.getAvps().getAvp(Avp.ADDITIONAL_SERVING_NODE); + if (additionalServingNodeAvp != null) { + try { + Avp gmlcAddressAvp = additionalServingNodeAvp.getGrouped().getAvp(Avp.GMLC_ADDRESS); + if (gmlcAddressAvp != null){ + return gmlcAddressAvp.getAddress(); + } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC-Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isPPRAddressAVPPresent(){ + return super.message.getAvps().getAvp(Avp.PPR_ADDRESS) != null; + } + + @Override + public java.net.InetAddress getPPRAddress(){ + Avp pprAddressAvp = super.message.getAvps().getAvp(Avp.PPR_ADDRESS); + if (pprAddressAvp != null) { + try { + return pprAddressAvp.getAddress(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain PPR-Address AVP value", e); + } + } + return null; + } + + @Override + public boolean isRIAFlagsAVPPresent() { + return super.message.getAvps().getAvp(Avp.RIA_FLAGS) != null; + } + + @Override + public long getRIAFLags(){ + Avp riaFlagsAvp = super.message.getAvps().getAvp(Avp.RIA_FLAGS); + if (riaFlagsAvp != null) { + try { + return riaFlagsAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain RIA-FLAGS AVP value", e); + } + } + return -1; + } + + public Avp getResultCodeAvp() throws AvpDataException { + return null; + } + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoRequestImpl.java new file mode 100644 index 000000000..42f1fe067 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoRequestImpl.java @@ -0,0 +1,122 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slh; + +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.jdiameter.api.Message; + +/** + * @author Fernando Mendioroz + * + */ +public class LCSRoutingInfoRequestImpl extends AppRequestEventImpl implements LCSRoutingInfoRequest { + + private static final long serialVersionUID = 1L; + + protected static final Logger logger = LoggerFactory.getLogger(LCSRoutingInfoRequestImpl.class); + + public LCSRoutingInfoRequestImpl(Message message) { + super(message); + message.setRequest(true); + } + + @Override + public boolean isUserNameAVPPresent() { + return super.message.getAvps().getAvp(Avp.USER_NAME) != null; // IE: IMSI + } + + @Override + public String getUserName() { + Avp userNameAvp = super.message.getAvps().getAvp(Avp.USER_NAME); + if (userNameAvp != null) { + try { + return userNameAvp.getUTF8String(); // IE: IMSI mapped to User-Name + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain User-Name AVP value (IMSI)", e); + } + } + return null; + } + + @Override + public boolean isMSISDNAVPPresent() { + return super.message.getAvps().getAvp(Avp.MSISDN) != null; + } + + @Override + public byte[] getMSISDN() { + Avp msisdnAvp = super.message.getAvps().getAvp(Avp.MSISDN); + if (msisdnAvp != null) { + try { + return msisdnAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MSISDN AVP value", e); + } + } + return null; + } + + @Override + public boolean isGMLCNumberAVPPresent() { + return super.message.getAvps().getAvp(Avp.GMLC_NUMBER) != null; + } + + @Override + public byte[] getGMLCNumber() { + Avp gmlcNumberAvp = super.message.getAvps().getAvp(Avp.GMLC_NUMBER); + if (gmlcNumberAvp != null) { + try { + return gmlcNumberAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC-Number AVP value", e); + } + } + return null; + } + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataFactory.java new file mode 100644 index 000000000..a1c6a4534 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataFactory.java @@ -0,0 +1,73 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slh; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.client.impl.app.slh.ClientSLhSessionDataLocalImpl; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.jdiameter.server.impl.app.slh.ServerSLhSessionDataLocalImpl; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLhLocalSessionDataFactory implements IAppSessionDataFactory { + + public ISLhSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLhSession.class)) { + ClientSLhSessionDataLocalImpl data = new ClientSLhSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else if (clazz.equals(ServerSLhSession.class)) { + ServerSLhSessionDataLocalImpl data = new ServerSLhSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else { + throw new IllegalArgumentException("Invalid Session Class: " + clazz.toString()); + } + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataImpl.java new file mode 100644 index 000000000..f47b8682f --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataImpl.java @@ -0,0 +1,86 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slh; + +import java.io.Serializable; + +import org.jdiameter.api.Request; +import org.jdiameter.common.api.app.AppSessionDataLocalImpl; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.jdiameter.common.api.app.slh.SLhSessionState; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLhLocalSessionDataImpl extends AppSessionDataLocalImpl implements ISLhSessionData { + + protected SLhSessionState state = SLhSessionState.IDLE; + protected Request buffer; + protected Serializable tsTimerId; + + public void setSLhSessionState(SLhSessionState state) { + this.state = state; + } + + public SLhSessionState getSLhSessionState() { + return this.state; + } + + public Serializable getTsTimerId() { + return this.tsTimerId; + } + + public void setTsTimerId(Serializable tid) { + this.tsTimerId = tid; + } + + public void setBuffer(Request buffer) { + this.buffer = buffer; + } + + public Request getBuffer() { + return this.buffer; + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSession.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSession.java new file mode 100644 index 000000000..93ebac696 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSession.java @@ -0,0 +1,155 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slh; + +import java.io.Serializable; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.app.StateMachine; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.AppSessionImpl; +import org.jdiameter.common.api.app.slh.ISLhMessageFactory; +import org.jdiameter.common.api.app.slh.ISLhSessionData; + +/** + * @author Fernando Mendioroz + * + */ + +public abstract class SLhSession extends AppSessionImpl implements NetworkReqListener, StateMachine { + + public static final int _TX_TIMEOUT = 30 * 1000; + + protected Lock sendAndStateLock = new ReentrantLock(); + + @SuppressWarnings("rawtypes") + protected transient List stateListeners = new CopyOnWriteArrayList(); + protected transient ISLhMessageFactory messageFactory; + + protected static final String TIMER_NAME_MSG_TIMEOUT = "MSG_TIMEOUT"; + protected ISLhSessionData sessionData; + + public SLhSession(ISessionFactory sf, ISLhSessionData sessionData) { + super(sf, sessionData); + this.sessionData = sessionData; + } + + @SuppressWarnings("rawtypes") + public void addStateChangeNotification(StateChangeListener listener) { + if (!stateListeners.contains(listener)) { + stateListeners.add(listener); + } + } + + @SuppressWarnings("rawtypes") + public void removeStateChangeNotification(StateChangeListener listener) { + stateListeners.remove(listener); + } + + public boolean isStateless() { + return true; + } + + @Override + public boolean isReplicable() { + return false; + } + + protected void startMsgTimer() { + try { + sendAndStateLock.lock(); + sessionData.setTsTimerId(super.timerFacility.schedule(getSessionId(), TIMER_NAME_MSG_TIMEOUT, _TX_TIMEOUT)); + } finally { + sendAndStateLock.unlock(); + } + } + + protected void cancelMsgTimer() { + try { + sendAndStateLock.lock(); + final Serializable timerId = this.sessionData.getTsTimerId(); + if (timerId == null) { + return; + } + super.timerFacility.cancel(timerId); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((sessionData == null) ? 0 : sessionData.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + SLhSession other = (SLhSession) obj; + if (sessionData == null) { + if (other.sessionData != null) { + return false; + } + } else if (!sessionData.equals(other.sessionData)) { + return false; + } + return true; + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSessionFactoryImpl.java new file mode 100644 index 000000000..9b4642acb --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSessionFactoryImpl.java @@ -0,0 +1,290 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.common.impl.app.slh; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.SessionFactory; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ClientSLhSessionListener; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.api.slh.ServerSLhSessionListener; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.client.impl.app.slh.IClientSLhSessionData; +import org.jdiameter.client.impl.app.slh.SLhClientSessionImpl; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slh.ISLhMessageFactory; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.jdiameter.common.api.app.slh.ISLhSessionFactory; +import org.jdiameter.common.api.data.ISessionDatasource; +import org.jdiameter.server.impl.app.slh.IServerSLhSessionData; +import org.jdiameter.server.impl.app.slh.SLhServerSessionImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLhSessionFactoryImpl implements ISLhSessionFactory, ServerSLhSessionListener, ClientSLhSessionListener, + ISLhMessageFactory, StateChangeListener { + + private static final Logger logger = LoggerFactory.getLogger(SLhSessionFactoryImpl.class); + + protected ISessionFactory sessionFactory; + + protected ServerSLhSessionListener serverSessionListener; + protected ClientSLhSessionListener clientSessionListener; + + protected ISLhMessageFactory messageFactory; + protected StateChangeListener stateListener; + protected ISessionDatasource iss; + protected IAppSessionDataFactory sessionDataFactory; + + public SLhSessionFactoryImpl() { + }; + + public SLhSessionFactoryImpl(SessionFactory sessionFactory) { + super(); + init(sessionFactory); + } + + public void init(SessionFactory sessionFactory) { + this.sessionFactory = (ISessionFactory) sessionFactory; + this.iss = this.sessionFactory.getContainer().getAssemblerFacility().getComponentInstance(ISessionDatasource.class); + this.sessionDataFactory = (IAppSessionDataFactory) this.iss.getDataFactory(ISLhSessionData.class); + } + + /** + * @return the serverSessionListener + */ + public ServerSLhSessionListener getServerSessionListener() { + return serverSessionListener != null ? serverSessionListener : this; + } + + /** + * @param serverSessionListener the serverSessionListener to set + */ + public void setServerSessionListener(ServerSLhSessionListener serverSessionListener) { + this.serverSessionListener = serverSessionListener; + } + + /** + * @return the serverSessionListener + */ + public ClientSLhSessionListener getClientSessionListener() { + return clientSessionListener != null ? clientSessionListener : this; + } + + /** + * @param clientSessionListener the clientSessionListener to set + */ + public void setClientSessionListener(ClientSLhSessionListener clientSessionListener) { + this.clientSessionListener = clientSessionListener; + } + + /** + * @return the messageFactory + */ + public ISLhMessageFactory getMessageFactory() { + return messageFactory != null ? messageFactory : this; + } + + /** + * @param messageFactory the messageFactory to set + */ + public void setMessageFactory(ISLhMessageFactory messageFactory) { + this.messageFactory = messageFactory; + } + + /** + * @return the stateListener + */ + public StateChangeListener getStateListener() { + return stateListener != null ? stateListener : this; + } + + /** + * @param stateListener the stateListener to set + */ + public void setStateListener(StateChangeListener stateListener) { + this.stateListener = stateListener; + } + + public AppSession getSession(String sessionId, Class aClass) { + if (sessionId == null) { + throw new IllegalArgumentException("SessionId must not be null"); + } + if (!this.iss.exists(sessionId)) { + return null; + } + AppSession appSession = null; + try { + if (aClass == ServerSLhSession.class) { + IServerSLhSessionData sessionData = (IServerSLhSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLhSession.class, sessionId); + SLhServerSessionImpl serverSession = new SLhServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLhSession.class) { + IClientSLhSessionData sessionData = (IClientSLhSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLhSession.class, sessionId); + SLhClientSessionImpl clientSession = new SLhClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLhSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLh Session.", e); + } + return appSession; + } + + public AppSession getNewSession(String sessionId, Class aClass, ApplicationId applicationId, + Object[] args) { + AppSession appSession = null; + + try { + if (aClass == ServerSLhSession.class) { + if (sessionId == null) { + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } + } + IServerSLhSessionData sessionData = (IServerSLhSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLhSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLhServerSessionImpl serverSession = new SLhServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + + iss.addSession(serverSession); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLhSession.class) { + if (sessionId == null) { + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } + } + IClientSLhSessionData sessionData = (IClientSLhSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLhSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLhClientSessionImpl clientSession = new SLhClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + + iss.addSession(clientSession); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLhSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLh Session.", e); + } + return appSession; + } + + public void stateChanged(Enum oldState, Enum newState) { + logger.info("Diameter SLh Session Factory :: stateChanged :: oldState[{}], newState[{}]", oldState, newState); + } + + public long getApplicationId() { + return 16777291; + } + + public void stateChanged(AppSession source, Enum oldState, Enum newState) { + logger.info("Diameter SLh Session Factory :: stateChanged :: Session, [{}], oldState[{}], newState[{}]", + new Object[] { source, oldState, newState }); + } + + public LCSRoutingInfoAnswer createLCSRoutingInfoAnswer(Answer answer) { + return new LCSRoutingInfoAnswerImpl(answer); + } + + public LCSRoutingInfoRequest createLCSRoutingInfoRequest(Request request) { + return new LCSRoutingInfoRequestImpl(request); + } + + public void doLCSRoutingInfoRequestEvent(ServerSLhSession appSession, LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLh Session Factory :: doLCSRoutingInfoRequestEvent :: appSession[{}], Request[{}]", + appSession, request); + } + + public void doOtherEvent(AppSession appSession, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLh Session Factory :: doOtherEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } + + public void doLCSRoutingInfoAnswerEvent(ClientSLhSession appSession, LCSRoutingInfoRequest request, + LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info( + "Diameter SLh Session Factory :: doLCSRoutingInfoAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java index d066798e6..017451023 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java @@ -62,6 +62,8 @@ import org.jdiameter.common.api.app.s13.IS13SessionData; import org.jdiameter.common.api.app.s6a.IS6aSessionData; import org.jdiameter.common.api.app.sh.IShSessionData; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.jdiameter.common.api.app.slh.ISLhSessionData; import org.jdiameter.common.api.data.ISessionDatasource; import org.jdiameter.common.impl.app.acc.AccLocalSessionDataFactory; import org.jdiameter.common.impl.app.auth.AuthLocalSessionDataFactory; @@ -74,6 +76,8 @@ import org.jdiameter.common.impl.app.s13.S13LocalSessionDataFactory; import org.jdiameter.common.impl.app.s6a.S6aLocalSessionDataFactory; import org.jdiameter.common.impl.app.sh.ShLocalSessionDataFactory; +import org.jdiameter.common.impl.app.slg.SLgLocalSessionDataFactory; +import org.jdiameter.common.impl.app.slh.SLhLocalSessionDataFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,6 +109,8 @@ public LocalDataSource() { appSessionDataFactories.put(IRxSessionData.class, new RxLocalSessionDataFactory()); appSessionDataFactories.put(IS6aSessionData.class, new S6aLocalSessionDataFactory()); appSessionDataFactories.put(IS13SessionData.class, new S13LocalSessionDataFactory()); + appSessionDataFactories.put(ISLhSessionData.class, new SLhLocalSessionDataFactory()); + appSessionDataFactories.put(ISLgSessionData.class, new SLgLocalSessionDataFactory()); } public LocalDataSource(IContainer container) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/timer/LocalTimerFacilityImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/timer/LocalTimerFacilityImpl.java index f08b3c700..c2c2b2302 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/timer/LocalTimerFacilityImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/timer/LocalTimerFacilityImpl.java @@ -55,7 +55,6 @@ import org.apache.commons.pool.impl.GenericObjectPool; import org.jdiameter.api.BaseSession; import org.jdiameter.client.api.IContainer; -import org.jdiameter.client.impl.BaseSessionImpl; import org.jdiameter.common.api.concurrent.IConcurrentFactory; import org.jdiameter.common.api.data.ISessionDatasource; import org.jdiameter.common.api.timer.ITimerFacility; @@ -97,7 +96,6 @@ public void cancel(Serializable f) { if (f != null && f instanceof TimerTaskHandle) { TimerTaskHandle timerTaskHandle = (TimerTaskHandle) f; if (timerTaskHandle.future != null) { - logger.debug("Cancelling timer with id [{}] and delay [{}]", timerTaskHandle.id, timerTaskHandle.future.getDelay(TimeUnit.MILLISECONDS)); if (executor.remove((Runnable) timerTaskHandle.future)) { timerTaskHandle.future.cancel(false); returnTimerTaskHandle(timerTaskHandle); @@ -169,24 +167,18 @@ private final class TimerTaskHandle implements Runnable, Externalizable { public void run() { try { BaseSession bSession = sessionDataSource.getSession(sessionId); - if (bSession == null) { + if (bSession == null || !bSession.isAppSession()) { // FIXME: error ? logger.error("Base Session is null for sessionId: {}", sessionId); return; } else { try { - if (!bSession.isAppSession()) { - BaseSessionImpl impl = (BaseSessionImpl) bSession; - impl.onTimer(timerName); - } - else { - AppSessionImpl impl = (AppSessionImpl) bSession; - impl.onTimer(timerName); - } + AppSessionImpl impl = (AppSessionImpl) bSession; + impl.onTimer(timerName); } catch (Exception e) { - logger.error("Caught exception from session object!", e); + logger.error("Caught exception from app session object!", e); } } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/AvpRepresentationImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/AvpRepresentationImpl.java index 435bdc840..31515b501 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/AvpRepresentationImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/AvpRepresentationImpl.java @@ -68,7 +68,6 @@ public class AvpRepresentationImpl implements AvpRepresentation { protected String ruleMandatory; protected String ruleProtected; protected String ruleVendorBit; - protected String originalType; protected String type; // String, in case user defines his own type // Usually this will be -1, as only SessionId has fixed position @@ -101,7 +100,6 @@ public AvpRepresentationImpl(AvpRepresentationImpl clone) { this.ruleMandatory = clone.ruleMandatory; this.ruleProtected = clone.ruleProtected; this.ruleVendorBit = clone.ruleVendorBit; - this.originalType = clone.originalType; this.type = clone.type; if (this.multiplicityIndicator.equals(_MP_NOT_ALLOWED)) { this.allowed = false; @@ -178,7 +176,7 @@ public AvpRepresentationImpl(int code, long vendor, String name) { } public AvpRepresentationImpl(String name, String description, int code, boolean mayEncrypt, String ruleMandatory, String ruleProtected, - String ruleVendorBit, long vendorId, String originalType, String type) { + String ruleVendorBit, long vendorId, String type) { // zero and more, since its definition. this(-1, code, vendorId, _MP_ZERO_OR_MORE, name); @@ -200,7 +198,6 @@ public AvpRepresentationImpl(String name, String description, int code, boolean this.ruleVendorBit = _DEFAULT_VENDOR; } - this.originalType = originalType; this.type = type; this._mandatory = this.ruleMandatory.equals("must"); this._protected = this.ruleProtected.equals("must"); @@ -412,11 +409,6 @@ public int getRuleVendorBitAsInt() { return Rule.valueOf(ruleVendorBit).ordinal(); } - @Override - public String getOriginalType() { - return originalType; - } - @Override public String getType() { return type; @@ -539,7 +531,6 @@ public Object clone() throws CloneNotSupportedException { clone.ruleMandatory = this.ruleMandatory; clone.ruleProtected = this.ruleProtected; clone.ruleVendorBit = this.ruleVendorBit; - clone.originalType = this.originalType; clone.type = this.type; List cloneChildren = new ArrayList(); diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java index a027c1810..1dd02f414 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/validation/DictionaryImpl.java @@ -331,8 +331,7 @@ protected void parseAvps(Document doc) { // ... // OR // ... - String avpOriginalType = UNDEFINED_AVP_TYPE; - String avpType = avpOriginalType; + String avpType = UNDEFINED_AVP_TYPE; List groupedAvpChilds = new ArrayList(); NodeList avpDefnChildNodes = avpNode.getChildNodes(); @@ -343,8 +342,7 @@ protected void parseAvps(Document doc) { Element avpDefnChildElement = (Element) avpDefnChildNode; if (avpDefnChildElement.getNodeName().equals("grouped")) { - avpOriginalType = "Grouped"; - avpType = avpOriginalType; + avpType = "Grouped"; // Let's fetch the childs // Format: @@ -405,8 +403,7 @@ protected void parseAvps(Document doc) { } } else if (avpDefnChildElement.getNodeName().equals("type")) { - avpOriginalType = avpDefnChildElement.getAttribute("type-name"); - avpType = avpOriginalType; + avpType = avpDefnChildElement.getAttribute("type-name"); //FIXME: baranowb: why this is like that? This changes type of AVP to primitive ONE..? Checks against type dont make sense, ie to check for Address type... avpType = typedefMap.get(avpType); @@ -425,7 +422,7 @@ else if (avpDefnChildElement.getNodeName().equals("type")) { AvpRepresentationImpl avp = null; avp = new AvpRepresentationImpl(avpName, "N/A", Integer.valueOf(avpCode), avpMayEncrypt.equals("yes"), avpMandatory, - avpProtected, avpVendorBit, vendorCode, avpOriginalType, avpType); + avpProtected, avpVendorBit, vendorCode, avpType); if (avp.isGrouped()) { avp.setChildren(groupedAvpChilds); @@ -457,8 +454,7 @@ else if (avpDefnChildElement.getNodeName().equals("type")) { logger.debug(new StringBuffer("[ERROR] Failed Parsing AVP: Name[").append(avpName).append("] Description[").append("N/A"). append("] Code[").append(avpCode).append("] May-Encrypt[").append(avpMayEncrypt).append("] Mandatory[").append(avpMandatory). append("] Protected [").append(avpProtected).append("] Vendor-Bit [").append(avpVendorBit).append("] Vendor-Id [").append(avpVendorId). - append("] Constrained[").append("N/A").append("] OriginalType [").append(avpOriginalType). - append("] Type [").append(avpType).append("]").toString(), e); + append("] Constrained[").append("N/A").append("] Type [").append(avpType).append("]").toString(), e); } } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/MutablePeerTableImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/MutablePeerTableImpl.java index 470b7f257..895f52bb9 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/MutablePeerTableImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/MutablePeerTableImpl.java @@ -513,15 +513,6 @@ public void messageReceived(String connKey, IMessage message) { metaData, config, null, fsmFactory, transportFactory, parser, statisticFactory, concurrentFactory); logger.debug("Created new peer instance [{}] and adding to peer table", peer); peer.setRealm(realm); - - Collection realms = router.getRealmTable().getRealms(realm); - for (Realm r : realms) { - if (r.getName().equals(realm)) { - logger.debug("Found the realm [{}] for the new peer [{}], adding it to it", realm, peer); - ((IRealm) r).addPeerName(host); - } - } - appendPeerToPeerTable(peer); logger.debug("Handle [{}] message on peer [{}]", message, peer); peer.handleMessage(message.isRequest() ? EventTypes.CER_EVENT : EventTypes.CER_EVENT, message, connKey); diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/NetworkImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/NetworkImpl.java index 7f07eb36d..7afb91f98 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/NetworkImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/NetworkImpl.java @@ -43,7 +43,6 @@ package org.jdiameter.server.impl; import java.util.Collection; -import java.util.List; import java.util.concurrent.ConcurrentHashMap; import org.jdiameter.api.ApplicationAlreadyUseException; @@ -58,7 +57,6 @@ import org.jdiameter.api.Statistic; import org.jdiameter.api.URI; import org.jdiameter.client.api.IMessage; -import org.jdiameter.client.api.controller.IRealmTable; import org.jdiameter.common.api.statistic.IStatistic; import org.jdiameter.common.api.statistic.IStatisticManager; import org.jdiameter.common.api.statistic.IStatisticRecord; @@ -272,12 +270,4 @@ public void setPeerManager(IMutablePeerTable manager) { this.manager = manager; } - public List getListPeers() { - return manager.getPeerTable(); - } - - public IRealmTable getRealmTable() { - return this.router.getRealmTable(); - } - } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/PeerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/PeerImpl.java index 6fc97061a..1b8be7612 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/PeerImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/PeerImpl.java @@ -258,8 +258,8 @@ public int processCerMessage(String key, IMessage message) { // Process cer Set newAppId = getCommonApplicationIds(message); if (newAppId.isEmpty()) { - if(logger.isWarnEnabled()) { - logger.warn("Processing CER failed, no common application. Message AppIds [{}]", message.getApplicationIdAvps()); + if (logger.isDebugEnabled()) { + logger.debug("Processing CER failed, no common application. Message AppIds [{}]", message.getApplicationIdAvps()); } return ResultCode.NO_COMMON_APPLICATION; } @@ -343,9 +343,6 @@ public boolean receiveMessage(IMessage message) { logger.debug("Receiving message in server."); boolean isProcessed = false; - // we set the peer in the message so we can later reply directly - message.setPeer(PeerImpl.this); - if (message.isRequest()) { IRequest req = message; Avp destRealmAvp = req.getAvps().getAvp(Avp.DESTINATION_REALM); @@ -413,8 +410,6 @@ public boolean receiveMessage(IMessage message) { return true; } - message.setPeer(PeerImpl.this); - switch (action) { case LOCAL: // always call listener - this covers realms // configured as localy processed and @@ -618,8 +613,6 @@ private boolean consumeMessage(IMessage message) { } isProcessed = true; if (isProcessed && answer != null) { - // we use the peer from the request to reply directly - answer.setPeer(message.getPeer()); sendMessage(answer); } if (statistic.isEnabled()) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/acc/ServerAccSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/acc/ServerAccSessionImpl.java index 278094528..78a5d7bc1 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/acc/ServerAccSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/acc/ServerAccSessionImpl.java @@ -407,10 +407,7 @@ private void cancelTsTimer() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_TS)) { + if (timerName.equals(TIMER_NAME_TS)) { if (context != null) { try { context.sessionTimeoutElapses(ServerAccSessionImpl.this); @@ -422,7 +419,7 @@ else if (timerName.equals(TIMER_NAME_TS)) { setState(IDLE); } else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); + // FIXME: ??? } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/auth/ServerAuthSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/auth/ServerAuthSessionImpl.java index 030c8765f..8f79a4461 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/auth/ServerAuthSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/auth/ServerAuthSessionImpl.java @@ -453,10 +453,7 @@ protected void cancelTsTimer() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_TS)) { + if (timerName.equals(TIMER_NAME_TS)) { try { sendAndStateLock.lock(); sessionData.setTsTimerId(null); @@ -469,9 +466,6 @@ else if (timerName.equals(TIMER_NAME_TS)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } @Override diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/ServerCCASessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/ServerCCASessionImpl.java index 12446261a..c3e2cf37e 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/ServerCCASessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cca/ServerCCASessionImpl.java @@ -200,12 +200,7 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE // Action: Send CC initial answer, reserve units, start Tcc // New State: OPEN if (isSuccess(resultCode)) { - Avp vtAvp = answer.getValidityTimeAvp(); - if (vtAvp == null) { - Avp mscc = answer.getMessage().getAvps().getAvp(Avp.MULTIPLE_SERVICES_CREDIT_CONTROL); - vtAvp = mscc != null ? mscc.getGrouped().getAvp(Avp.VALIDITY_TIME) : null; - } - startTcc(vtAvp); + startTcc(answer.getValidityTimeAvp()); newState = ServerCCASessionState.OPEN; } // Current State: IDLE @@ -258,12 +253,7 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE // Event: CC update request received and successfully processed // Action: Send CC update answer, debit used units, reserve new units, restart Tcc // New State: OPEN - Avp vtAvp = answer.getValidityTimeAvp(); - if (vtAvp == null) { - Avp mscc = answer.getMessage().getAvps().getAvp(Avp.MULTIPLE_SERVICES_CREDIT_CONTROL); - vtAvp = mscc != null ? mscc.getGrouped().getAvp(Avp.VALIDITY_TIME) : null; - } - startTcc(vtAvp); + startTcc(answer.getValidityTimeAvp()); } else { // Current State: OPEN @@ -407,8 +397,6 @@ private void startTcc(Avp validityAvp) { tccTimeout = 2 * context.getDefaultValidityTime(); } - logger.debug("Starting TCC timer with Validity-Avp[{}] and tccTimeout[{}] seconds", validityAvp, tccTimeout); - if (sessionData.getTccTimerId() != null) { stopTcc(true); //tccFuture = super.scheduler.schedule(new TccScheduledTask(this), defaultValue, TimeUnit.SECONDS); @@ -431,15 +419,9 @@ private void startTcc(Avp validityAvp) { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TCC_TIMER_NAME)) { + if (timerName.equals(TCC_TIMER_NAME)) { new TccScheduledTask(this).run(); } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } private void stopTcc(boolean willRestart) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cxdx/CxDxServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cxdx/CxDxServerSessionImpl.java index 033301563..d068a5141 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cxdx/CxDxServerSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/cxdx/CxDxServerSessionImpl.java @@ -395,10 +395,7 @@ protected void setState(CxDxSessionState newState) { @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(CxDxSession.TIMER_NAME_MSG_TIMEOUT)) { + if (timerName.equals(CxDxSession.TIMER_NAME_MSG_TIMEOUT)) { try { sendAndStateLock.lock(); try { @@ -414,9 +411,6 @@ else if (timerName.equals(CxDxSession.TIMER_NAME_MSG_TIMEOUT)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } private class RequestDelivery implements Runnable { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gq/GqServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gq/GqServerSessionImpl.java index fc1148d8e..786d2ce9f 100755 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gq/GqServerSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gq/GqServerSessionImpl.java @@ -479,10 +479,7 @@ protected void cancelTsTimer() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_TS)) { + if (timerName.equals(TIMER_NAME_TS)) { try { sendAndStateLock.lock(); sessionData.setTsTimerId(null); @@ -495,9 +492,6 @@ else if (timerName.equals(TIMER_NAME_TS)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } protected ReAuthAnswer createReAuthAnswer(Answer answer) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gx/ServerGxSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gx/ServerGxSessionImpl.java index d7ac1e3e5..df57e0f93 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gx/ServerGxSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/gx/ServerGxSessionImpl.java @@ -252,16 +252,12 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE // New State: IDLE // It's a failure, we wait for Tcc to fire -- FIXME: Alexandre: Should we? - newState = ServerGxSessionState.IDLE; } } catch (AvpDataException e) { throw new InternalException(e); } dispatchEvent(localEvent.getAnswer()); - if (newState != null) { - setState(newState); - } break; case RECEIVED_TERMINATE: listener.doCreditControlRequest(this, (GxCreditControlRequest) localEvent.getRequest()); @@ -414,15 +410,9 @@ private void startTcc(Avp validityAvp) { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TCC_TIMER_NAME)) { + if (timerName.equals(TCC_TIMER_NAME)) { new TccScheduledTask(this).run(); } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } private void stopTcc(boolean willRestart) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rf/ServerRfSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rf/ServerRfSessionImpl.java index 6e86e99fe..d5b01100d 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rf/ServerRfSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rf/ServerRfSessionImpl.java @@ -392,10 +392,7 @@ private void cancelTsTimer() { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TIMER_NAME_TS)) { + if (timerName.equals(TIMER_NAME_TS)) { if (context != null) { try { context.sessionTimeoutElapses(ServerRfSessionImpl.this); @@ -406,9 +403,6 @@ else if (timerName.equals(TIMER_NAME_TS)) { } setState(IDLE); } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } protected Answer createStopAnswer(Request request) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/ro/ServerRoSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/ro/ServerRoSessionImpl.java index e90b0b5cd..241b4a89e 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/ro/ServerRoSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/ro/ServerRoSessionImpl.java @@ -200,9 +200,7 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE // Action: Send CC initial answer, reserve units, start Tcc // New State: OPEN if (isSuccess(resultCode)) { - Avp mscc = answer.getMessage().getAvps().getAvp(Avp.MULTIPLE_SERVICES_CREDIT_CONTROL); - Avp vtAvp = mscc != null ? mscc.getGrouped().getAvp(Avp.VALIDITY_TIME) : null; - startTcc(vtAvp); + startTcc(answer.getValidityTimeAvp()); newState = ServerRoSessionState.OPEN; } // Current State: IDLE @@ -256,9 +254,7 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE // Event: CC update request received and successfully processed // Action: Send CC update answer, debit used units, reserve new units, restart Tcc // New State: OPEN - Avp mscc = answer.getMessage().getAvps().getAvp(Avp.MULTIPLE_SERVICES_CREDIT_CONTROL); - Avp vtAvp = mscc != null ? mscc.getGrouped().getAvp(Avp.VALIDITY_TIME) : null; - startTcc(vtAvp); + startTcc(answer.getValidityTimeAvp()); } else { // Current State: OPEN @@ -394,36 +390,36 @@ public void timeoutExpired(Request request) { } private void startTcc(Avp validityAvp) { - long tccTimeout; - - if (validityAvp != null) { - try { - tccTimeout = 2 * validityAvp.getUnsigned32(); - } - catch (AvpDataException e) { - logger.debug("Unable to retrieve Validity-Time AVP value, using default.", e); - tccTimeout = 2 * context.getDefaultValidityTime(); - } - } - else { - tccTimeout = 2 * context.getDefaultValidityTime(); - } - - logger.debug("Starting TCC timer with Validity-Avp[{}] and tccTimeout[{}] seconds", validityAvp, tccTimeout); - - if (sessionData.getTccTimerId() != null) { - stopTcc(true); - //tccFuture = super.scheduler.schedule(new TccScheduledTask(this), defaultValue, TimeUnit.SECONDS); - this.sessionData.setTccTimerId(super.timerFacility.schedule(this.getSessionId(), TCC_TIMER_NAME, tccTimeout * 1000)); - // FIXME: this accepts Future! - context.sessionSupervisionTimerReStarted(this, null); - } - else { - //tccFuture = super.scheduler.schedule(new TccScheduledTask(this), defaultValue, TimeUnit.SECONDS); - this.sessionData.setTccTimerId(super.timerFacility.schedule(this.getSessionId(), TCC_TIMER_NAME, tccTimeout * 1000)); - //FIXME: this accepts Future! - context.sessionSupervisionTimerStarted(this, null); - } + // There is no Validity-Time + //long tccTimeout; + // + //if(validityAvp != null) { + // try { + // tccTimeout = 2 * validityAvp.getUnsigned32(); + // } + // catch (AvpDataException e) { + // logger.debug("Unable to retrieve Validity-Time AVP value, using default.", e); + // tccTimeout = 2 * context.getDefaultValidityTime(); + // } + //} + //else { + // tccTimeout = 2 * context.getDefaultValidityTime(); + //} + // + //if(tccTimerId != null) { + // stopTcc(true); + // //tccFuture = super.scheduler.schedule(new TccScheduledTask(this), defaultValue, TimeUnit.SECONDS); + // tccTimerId = super.timerFacility.schedule(this.sessionId, TCC_TIMER_NAME, tccTimeout * 1000); + // // FIXME: this accepts Future! + // context.sessionSupervisionTimerReStarted(this, null); + //} + //else { + // //tccFuture = super.scheduler.schedule(new TccScheduledTask(this), defaultValue, TimeUnit.SECONDS); + // tccTimerId = super.timerFacility.schedule(this.sessionId, TCC_TIMER_NAME, tccTimeout * 1000); + // //FIXME: this accepts Future! + // context.sessionSupervisionTimerStarted(this, null); + //} + //super.sessionDataSource.updateSession(this); } /* @@ -433,24 +429,18 @@ private void startTcc(Avp validityAvp) { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(TCC_TIMER_NAME)) { + if (timerName.equals(TCC_TIMER_NAME)) { new TccScheduledTask(this).run(); } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } private void stopTcc(boolean willRestart) { - Serializable tccTimerId = this.sessionData.getTccTimerId(); + Serializable tccTimerId = sessionData.getTccTimerId(); if (tccTimerId != null) { // tccFuture.cancel(false); super.timerFacility.cancel(tccTimerId); // ScheduledFuture f = tccFuture; - this.sessionData.setTccTimerId(null); + sessionData.setTccTimerId(null); if (!willRestart) { context.sessionSupervisionTimerStopped(this, null); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rx/ServerRxSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rx/ServerRxSessionImpl.java index 53876812b..314f05708 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rx/ServerRxSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/rx/ServerRxSessionImpl.java @@ -246,7 +246,6 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE // Action: Send AA update answer with Result-Code != SUCCESS // New State: IDLE // It's a failure, we wait for Tcc to fire -- FIXME: Alexandre: Should we? - newState = ServerRxSessionState.IDLE; } } catch (AvpDataException e) { @@ -272,7 +271,6 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE // Action: Send AA update answer with Result-Code != SUCCESS // New State: IDLE // It's a failure, we wait for Tcc to fire -- FIXME: Alexandre: Should we? - newState = ServerRxSessionState.IDLE; } } catch (AvpDataException e) { @@ -348,12 +346,6 @@ public void receivedSuccessMessage(Request request, Answer answer) { */ @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } @Override diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s13/S13ServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s13/S13ServerSessionImpl.java index 93449f972..6ee368b75 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s13/S13ServerSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s13/S13ServerSessionImpl.java @@ -212,10 +212,7 @@ protected void setState(S13SessionState newState) { @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(S13Session.TIMER_NAME_MSG_TIMEOUT)) { + if (timerName.equals(S13Session.TIMER_NAME_MSG_TIMEOUT)) { try { sendAndStateLock.lock(); try { @@ -229,9 +226,6 @@ else if (timerName.equals(S13Session.TIMER_NAME_MSG_TIMEOUT)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } @Override diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s6a/S6aServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s6a/S6aServerSessionImpl.java index f531f36ee..fee538f10 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s6a/S6aServerSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/s6a/S6aServerSessionImpl.java @@ -391,10 +391,7 @@ protected void setState(S6aSessionState newState) { @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else if (timerName.equals(S6aSession.TIMER_NAME_MSG_TIMEOUT)) { + if (timerName.equals(S6aSession.TIMER_NAME_MSG_TIMEOUT)) { try { sendAndStateLock.lock(); try { @@ -410,9 +407,6 @@ else if (timerName.equals(S6aSession.TIMER_NAME_MSG_TIMEOUT)) { sendAndStateLock.unlock(); } } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } } @Override diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/sh/ShServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/sh/ShServerSessionImpl.java index 0daa56690..ec2b55f85 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/sh/ShServerSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/sh/ShServerSessionImpl.java @@ -341,12 +341,7 @@ else if (!sessionData.equals(other.sessionData)) { @Override public void onTimer(String timerName) { - if (timerName.equals(IDLE_SESSION_TIMER_NAME)) { - checkIdleAppSession(); - } - else { - logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId()); - } + logger.trace("onTimer({})", timerName); } private class RequestDelivery implements Runnable { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/Event.java new file mode 100644 index 000000000..4b6fd99f8 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/Event.java @@ -0,0 +1,107 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slg; + +import org.jdiameter.api.InternalException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateEvent; + +/** + * @author Fernando Mendioroz + * + */ + +public class Event implements StateEvent { + + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_PLR, RECEIVE_LRR + } + + AppEvent request; + AppEvent answer; + Type type; + + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } + + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } + + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } + + public AppEvent getRequest() { + return request; + } + + public AppEvent getAnswer() { + return answer; + } + + public int compareTo(Object o) { + return 0; + } + + public Object getData() { + return request != null ? request : answer; + } + + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); + } + } +} \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/IServerSLgSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/IServerSLgSessionData.java new file mode 100644 index 000000000..b83d79d1c --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/IServerSLgSessionData.java @@ -0,0 +1,54 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slg; + +import org.jdiameter.common.api.app.slg.ISLgSessionData; + +/** + * @author Fernando Mendioroz + * + */ + +public interface IServerSLgSessionData extends ISLgSessionData { + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/SLgServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/SLgServerSessionImpl.java new file mode 100644 index 000000000..3092e6b8e --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/SLgServerSessionImpl.java @@ -0,0 +1,332 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slg; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.EventListener; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.app.StateEvent; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.ServerSLgSessionListener; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.api.app.slg.ISLgMessageFactory; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.jdiameter.common.impl.app.AppAnswerEventImpl; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.jdiameter.common.impl.app.slg.SLgSession; +import org.jdiameter.server.impl.app.slg.Event.Type; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLgServerSessionImpl extends SLgSession + implements ServerSLgSession, EventListener, NetworkReqListener { + + private static final Logger logger = LoggerFactory.getLogger(SLgServerSessionImpl.class); + + // Factories and Listeners + // -------------------------------------------------- + private transient ServerSLgSessionListener listener; + protected long appId = -1; + protected IServerSLgSessionData sessionData; + + public SLgServerSessionImpl(IServerSLgSessionData sessionData, ISLgMessageFactory fct, ISessionFactory sf, + ServerSLgSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); + } + if ((this.appId = fct.getApplicationId()) < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); + } + + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + public void sendProvideLocationAnswer(ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, null, answer); + } + + public void sendLocationReportAnswer(LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, null, answer); + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLgSessionState.class ? (E) this.sessionData.getSLgSessionState() : null; + } + + @SuppressWarnings("unused") + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLgSessionState state = this.sessionData.getSLgSessionState(); + SLgSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + + switch (state) { + + case IDLE: + switch (eventType) { + + case RECEIVE_PLR: + this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); + super.cancelMsgTimer(); + super.startMsgTimer(); + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + listener.doProvideLocationRequestEvent(this, (ProvideLocationRequest) event.getData()); + break; + + case RECEIVE_LRR: + this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); + super.cancelMsgTimer(); + super.startMsgTimer(); + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + listener.doLocationReportRequestEvent(this, (LocationReportRequest) event.getData()); + break; + + case SEND_MESSAGE: + super.session.send(((AppEvent) event.getData()).getMessage(), this); + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + break; + + default: + logger.error("Wrong action in SLg Server FSM. State: IDLE, Event Type: {}", eventType); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLgSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLgSessionState.TERMINATED; + setState(newState); + } + break; + + default: + throw new InternalException( + "Should not receive more messages after initial. Command: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLg Server FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); + } + return true; + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); + } + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLgSessionState newState) { + SLgSessionState oldState = this.sessionData.getSLgSessionState(); + this.sessionData.setSLgSessionState(newState); + + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); + } + if (newState == SLgSessionState.TERMINATED || newState == SLgSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); + } + } + + @Override + public void onTimer(String timerName) { + if (timerName.equals(SLgSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); + try { + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); + } catch (Exception e) { + logger.debug("Failure handling Timeout event."); + } + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } + } + } + + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); + } + } + + private class RequestDelivery implements Runnable { + ServerSLgSession session; + Request request; + + public void run() { + try { + switch (request.getCommandCode()) { + case ProvideLocationRequest.code: + handleEvent( + new Event(Event.Type.RECEIVE_PLR, messageFactory.createProvideLocationRequest(request), null)); + break; + + case LocationReportRequest.code: + handleEvent( + new Event(Event.Type.RECEIVE_LRR, messageFactory.createLocationReportRequest(request), null)); + break; + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; + } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } + } + } + + private class AnswerDelivery implements Runnable { + ServerSLgSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; + } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } + } + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/ServerSLgSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/ServerSLgSessionDataLocalImpl.java new file mode 100644 index 000000000..adfebd71b --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/ServerSLgSessionDataLocalImpl.java @@ -0,0 +1,55 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slg; + +import org.jdiameter.common.impl.app.slg.SLgLocalSessionDataImpl; + +/** + * @author Fernando Mendioroz + * + */ + +public class ServerSLgSessionDataLocalImpl extends SLgLocalSessionDataImpl implements IServerSLgSessionData { + public ServerSLgSessionDataLocalImpl() { + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/Event.java new file mode 100644 index 000000000..96e2857db --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/Event.java @@ -0,0 +1,107 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slh; + +import org.jdiameter.api.InternalException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateEvent; + +/** + * @author Fernando Mendioroz + * + */ + +public class Event implements StateEvent { + + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_RIR; + } + + AppEvent request; + AppEvent answer; + Type type; + + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } + + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } + + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } + + public AppEvent getRequest() { + return request; + } + + public AppEvent getAnswer() { + return answer; + } + + public int compareTo(Object o) { + return 0; + } + + public Object getData() { + return request != null ? request : answer; + } + + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/IServerSLhSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/IServerSLhSessionData.java new file mode 100644 index 000000000..b6fc39318 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/IServerSLhSessionData.java @@ -0,0 +1,54 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slh; + +import org.jdiameter.common.api.app.slh.ISLhSessionData; + +/** + * @author Fernando Mendioroz + * + */ + +public interface IServerSLhSessionData extends ISLhSessionData { + +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/SLhServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/SLhServerSessionImpl.java new file mode 100644 index 000000000..bb04c95bf --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/SLhServerSessionImpl.java @@ -0,0 +1,311 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slh; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.EventListener; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppEvent; +import org.jdiameter.api.app.StateChangeListener; +import org.jdiameter.api.app.StateEvent; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.api.slh.ServerSLhSessionListener; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.api.app.slh.ISLhMessageFactory; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.jdiameter.common.impl.app.AppAnswerEventImpl; +import org.jdiameter.common.impl.app.AppRequestEventImpl; +import org.jdiameter.common.impl.app.slh.SLhSession; +import org.jdiameter.server.impl.app.slh.Event.Type; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Fernando Mendioroz + * + */ + +public class SLhServerSessionImpl extends SLhSession + implements ServerSLhSession, EventListener, NetworkReqListener { + + private static final Logger logger = LoggerFactory.getLogger(SLhServerSessionImpl.class); + + // Factories and Listeners + // -------------------------------------------------- + private transient ServerSLhSessionListener listener; + protected long appId = -1; + protected IServerSLhSessionData sessionData; + + public SLhServerSessionImpl(IServerSLhSessionData sessionData, ISLhMessageFactory fct, ISessionFactory sf, + ServerSLhSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); + } + if ((this.appId = fct.getApplicationId()) < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); + } + + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + public void sendLCSRoutingInfoAnswer(LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, null, answer); + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLhSessionState.class ? (E) this.sessionData.getSLhSessionState() : null; + } + + @SuppressWarnings("unused") + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLhSessionState state = this.sessionData.getSLhSessionState(); + SLhSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + + switch (state) { + + case IDLE: + switch (eventType) { + + case RECEIVE_RIR: + this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); + super.cancelMsgTimer(); + super.startMsgTimer(); + newState = SLhSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + listener.doLCSRoutingInfoRequestEvent(this, (LCSRoutingInfoRequest) event.getData()); + break; + + case SEND_MESSAGE: + super.session.send(((AppEvent) event.getData()).getMessage(), this); + newState = SLhSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + break; + + default: + logger.error("Wrong action in SLh Server FSM. State: IDLE, Event Type: {}", eventType); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLhSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLhSessionState.TERMINATED; + setState(newState); + } + break; + + default: + throw new InternalException( + "Should not receive more messages after initial. Command: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLh Server FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); + } + return true; + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); + } + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLhSessionState newState) { + SLhSessionState oldState = this.sessionData.getSLhSessionState(); + this.sessionData.setSLhSessionState(newState); + + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); + } + if (newState == SLhSessionState.TERMINATED || newState == SLhSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); + } + } + + @Override + public void onTimer(String timerName) { + if (timerName.equals(SLhSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); + try { + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); + } catch (Exception e) { + logger.debug("Failure handling Timeout event."); + } + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } + } + } + + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); + } + } + + private class RequestDelivery implements Runnable { + ServerSLhSession session; + Request request; + + public void run() { + try { + switch (request.getCommandCode()) { + case LCSRoutingInfoRequest.code: + handleEvent( + new Event(Event.Type.RECEIVE_RIR, messageFactory.createLCSRoutingInfoRequest(request), null)); + break; + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; + } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } + } + } + + private class AnswerDelivery implements Runnable { + ServerSLhSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; + } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } + } + } +} \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/ServerSLhSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/ServerSLhSessionDataLocalImpl.java new file mode 100644 index 000000000..c299715b4 --- /dev/null +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/ServerSLhSessionDataLocalImpl.java @@ -0,0 +1,55 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.jdiameter.server.impl.app.slh; + +import org.jdiameter.common.impl.app.slh.SLhLocalSessionDataImpl; + +/** + * @author Fernando Mendioroz + * + */ + +public class ServerSLhSessionDataLocalImpl extends SLhLocalSessionDataImpl implements IServerSLhSessionData { + public ServerSLhSessionDataLocalImpl() { + } +} diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/helpers/XMLConfiguration.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/helpers/XMLConfiguration.java index 7a69f3d8c..0760eb62c 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/helpers/XMLConfiguration.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/helpers/XMLConfiguration.java @@ -109,7 +109,6 @@ import static org.jdiameter.client.impl.helpers.Parameters.SDUseClientMode; import static org.jdiameter.client.impl.helpers.Parameters.Security; import static org.jdiameter.client.impl.helpers.Parameters.SecurityRef; -import static org.jdiameter.client.impl.helpers.Parameters.SessionTimeOut; import static org.jdiameter.client.impl.helpers.Parameters.Statistics; import static org.jdiameter.client.impl.helpers.Parameters.StatisticsActiveList; import static org.jdiameter.client.impl.helpers.Parameters.StatisticsEnabled; @@ -365,9 +364,6 @@ else if (nodeName.equals("DpaTimeOut")) { else if (nodeName.equals("RecTimeOut")) { add(RecTimeOut, getLongValue(c.item(i))); } - else if (nodeName.equals("SessionTimeOut")) { - add(SessionTimeOut, getLongValue(c.item(i))); - } else if (nodeName.equals("BindDelay")) { add(BindDelay, getLongValue(c.item(i))); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/io/tcp/NetworkGuard.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/io/tcp/NetworkGuard.java index 866f7058a..2b21036d7 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/io/tcp/NetworkGuard.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/io/tcp/NetworkGuard.java @@ -281,9 +281,6 @@ public void cleanTask() { } serverSocket = null; } - if (binder != null) { - binder.shutdown(); - } } @Override diff --git a/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-client.xsd b/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-client.xsd index 1a4eca615..d283ced65 100644 --- a/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-client.xsd +++ b/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-client.xsd @@ -167,14 +167,6 @@ - - - Session idle time out in milliseconds. - - - - - Default stop time out in milliseconds. diff --git a/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-server.xsd b/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-server.xsd index 80fdcd87d..b30936af1 100644 --- a/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-server.xsd +++ b/core/jdiameter/impl/src/main/resources/META-INF/jdiameter-server.xsd @@ -232,14 +232,6 @@ - - - Session idle time out in milliseconds. - - - - - Default stop time out in milliseconds. diff --git a/core/jdiameter/impl/src/test/java/org/jdiameter/client/impl/router/TestRouter.java b/core/jdiameter/impl/src/test/java/org/jdiameter/client/impl/router/TestRouter.java index 15be520ac..e65717fbe 100644 --- a/core/jdiameter/impl/src/test/java/org/jdiameter/client/impl/router/TestRouter.java +++ b/core/jdiameter/impl/src/test/java/org/jdiameter/client/impl/router/TestRouter.java @@ -312,10 +312,6 @@ public boolean isWrapperFor(Class iface) throws InternalException { public T unwrap(Class iface) throws InternalException { return null; } - - public List getAllRealmSet(){ - return null; - } } private static class PeerTest extends AbstractPeer implements IPeer { diff --git a/core/mux/common/config/dictionary.xml b/core/mux/common/config/dictionary.xml index 6f7c02bc2..d1b4dfaab 100644 --- a/core/mux/common/config/dictionary.xml +++ b/core/mux/common/config/dictionary.xml @@ -7867,4 +7867,637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/mux/common/config/jdiameter-infinispan.xml b/core/mux/common/config/jdiameter-infinispan.xml deleted file mode 100644 index 0d2eed397..000000000 --- a/core/mux/common/config/jdiameter-infinispan.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core/mux/common/config/jdiameter-jbc.xml b/core/mux/common/config/jdiameter-jbc.xml index 2d91d00eb..ba2cb2b2e 100644 --- a/core/mux/common/config/jdiameter-jbc.xml +++ b/core/mux/common/config/jdiameter-jbc.xml @@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexer.java b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexer.java index cdcae4f99..d033edf2e 100644 --- a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexer.java +++ b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexer.java @@ -72,7 +72,6 @@ import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -100,7 +99,6 @@ import org.jdiameter.api.MutablePeerTable; import org.jdiameter.api.Network; import org.jdiameter.api.NetworkReqListener; -import org.jdiameter.api.Peer; import org.jdiameter.api.PeerTable; import org.jdiameter.api.Request; import org.jdiameter.api.ResultCode; @@ -605,13 +603,12 @@ public void _LocalPeer_addIPAddress(String ipAddress) throws MBeanException { if (IP_PATTERN.matcher(ipAddress).matches()) { Configuration[] oldIPAddressesConfig = getMutableConfiguration().getChildren(OwnIPAddresses.ordinal()); - List newIPAddressesConfig = new ArrayList (Arrays.asList(oldIPAddressesConfig)); - + List newIPAddressesConfig = Arrays.asList(oldIPAddressesConfig); AppConfiguration newIPAddress = getClientConfiguration().add(OwnIPAddress, ipAddress); newIPAddressesConfig.add(newIPAddress); - getMutableConfiguration().setChildren( OwnIPAddresses.ordinal(), - (Configuration[]) newIPAddressesConfig.toArray(new Configuration[newIPAddressesConfig.size()])); + getMutableConfiguration().setChildren(OwnIPAddresses.ordinal(), (Configuration[]) newIPAddressesConfig.toArray()); + if (logger.isInfoEnabled()) { logger.info("Local Peer IP Address successfully changed to " + ipAddress + ". Restart to Diameter stack is needed to apply changes."); } @@ -621,16 +618,6 @@ public void _LocalPeer_addIPAddress(String ipAddress) throws MBeanException { } } - @Override - public List _Network_Peers_retrievePeer() throws MBeanException { - try { - NetworkImpl n = (NetworkImpl) stack.unwrap(Network.class); - return n.getListPeers(); - } - catch (InternalException e) { - throw new MBeanException(e, "Failed to retrieve peer"); - } - } /* * (non-Javadoc) * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_removeIPAddress(java.lang.String) @@ -719,13 +706,13 @@ public void _LocalPeer_setVendorId(long vendorId) throws MBeanException { /* * (non-Javadoc) - * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_Network_Peers_addPeer(java.lang.String, boolean, int, String) + * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_Network_Peers_addPeer(java.lang.String, boolean, int) */ @Override - public void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating, String realm) throws MBeanException { + public void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating) throws MBeanException { try { NetworkImpl n = (NetworkImpl) stack.unwrap(Network.class); - /*Peer p =*/ n.addPeer(name, realm, attemptConnect); + /*Peer p =*/ n.addPeer(name, "", attemptConnect); // FIXME: This requires realm... } catch (IllegalArgumentException e) { logger.warn(e.getMessage()); @@ -952,15 +939,14 @@ public Set _LocalPeer_getCommonApplicationIds() throws MBeanExcep @Override public String[] _Network_Realms_getRealms() throws MBeanException { - try{ - org.jdiameter.server.impl.NetworkImpl n = (org.jdiameter.server.impl.NetworkImpl) stack.unwrap(org.jdiameter.api.Network.class); - List list = n.getRealmTable().getAllRealmSet(); - String [] stringArray = list.toArray(new String[list.size()]); - return stringArray; - } - catch (Exception e) { - throw new MBeanException(e); + Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); + String[] realmNames = new String[realmEntries.length]; + + for (int i = 0; i < realmEntries.length; i++) { + realmNames[i] = realmEntries[i].getStringValue(RealmName.ordinal(), DEFAULT_STRING); } + + return realmNames; } @Override diff --git a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7.java b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7.java index 5f576b28e..e18d73ecc 100644 --- a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7.java +++ b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7.java @@ -1,5 +1,6 @@ /* * TeleStax, Open Source Cloud Communications + * * Copyright 2011-2015, Telestax Inc. and individual contributors * by the @authors tag. * @@ -19,955 +20,274 @@ package org.mobicents.diameter.stack; -import static org.jdiameter.client.impl.helpers.Parameters.CeaTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.Concurrent; -import static org.jdiameter.client.impl.helpers.Parameters.ConcurrentEntityDescription; -import static org.jdiameter.client.impl.helpers.Parameters.ConcurrentEntityName; -import static org.jdiameter.client.impl.helpers.Parameters.ConcurrentEntityPoolSize; -import static org.jdiameter.client.impl.helpers.Parameters.DpaTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.DwaTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.IacTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.MessageTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.OwnDiameterURI; -import static org.jdiameter.client.impl.helpers.Parameters.OwnIPAddress; -import static org.jdiameter.client.impl.helpers.Parameters.OwnRealm; -import static org.jdiameter.client.impl.helpers.Parameters.OwnVendorID; -import static org.jdiameter.client.impl.helpers.Parameters.RealmEntry; -import static org.jdiameter.client.impl.helpers.Parameters.RealmTable; -import static org.jdiameter.client.impl.helpers.Parameters.RecTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.StatisticsLoggerDelay; -import static org.jdiameter.client.impl.helpers.Parameters.StatisticsLoggerPause; -import static org.jdiameter.client.impl.helpers.Parameters.StopTimeOut; -import static org.jdiameter.client.impl.helpers.Parameters.UseUriAsFqdn; -import static org.jdiameter.server.impl.helpers.Parameters.AcceptUndefinedPeer; -import static org.jdiameter.server.impl.helpers.Parameters.DuplicateTimer; -import static org.jdiameter.server.impl.helpers.Parameters.OwnIPAddresses; -import static org.jdiameter.server.impl.helpers.Parameters.RealmHosts; -import static org.jdiameter.server.impl.helpers.Parameters.RealmName; - -import java.io.InputStream; import java.net.InetAddress; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; import java.util.Set; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReentrantLock; -import java.util.regex.Pattern; -import org.jdiameter.api.Answer; -import org.jdiameter.api.ApplicationAlreadyUseException; +import javax.ejb.Local; + import org.jdiameter.api.ApplicationId; -import org.jdiameter.api.Avp; -import org.jdiameter.api.Configuration; -import org.jdiameter.api.DisconnectCause; -import org.jdiameter.api.EventListener; -import org.jdiameter.api.InternalException; -import org.jdiameter.api.LocalAction; -import org.jdiameter.api.Message; -import org.jdiameter.api.MutableConfiguration; -import org.jdiameter.api.MutablePeerTable; -import org.jdiameter.api.Network; -import org.jdiameter.api.NetworkReqListener; -import org.jdiameter.api.PeerTable; -import org.jdiameter.api.Request; -import org.jdiameter.api.ResultCode; -import org.jdiameter.api.Session; import org.jdiameter.api.Stack; -import org.jdiameter.client.api.controller.IRealm; -import org.jdiameter.client.api.controller.IRealmTable; -import org.jdiameter.client.impl.DictionarySingleton; -import org.jdiameter.client.impl.controller.PeerImpl; -import org.jdiameter.client.impl.helpers.AppConfiguration; -import org.jdiameter.common.impl.validation.DictionaryImpl; -import org.jdiameter.server.impl.NetworkImpl; -import org.jdiameter.server.impl.StackImpl; -import org.jdiameter.server.impl.helpers.XMLConfiguration; import org.mobicents.diameter.api.DiameterMessageFactory; import org.mobicents.diameter.api.DiameterProvider; -import org.mobicents.diameter.dictionary.AvpDictionary; import org.mobicents.diameter.stack.management.DiameterConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * * @author Alexandre Mendonca */ -public class DiameterStackMultiplexerAS7 implements DiameterStackMultiplexerAS7MBean, DiameterProvider, NetworkReqListener, EventListener, - DiameterMessageFactory { - - private static final Logger logger = LoggerFactory.getLogger(DiameterStackMultiplexerAS7.class); +@Local +public interface DiameterStackMultiplexerAS7 { - public static final String OBJECT_NAME = "diameter.mobicents:service=DiameterStackMultiplexer"; + String MBEAN_NAME_PREFIX = "diameter:Service=DiameterStackMultiplexer,Name="; - protected Stack stack = null; + void registerListener(DiameterListener listener, ApplicationId[] appIds) throws IllegalStateException; - protected HashMap> listenerToAppId = - new HashMap>(3); - protected HashMap appIdToListener = new HashMap(3); + void unregisterListener(DiameterListener listener); - // This is for synch - protected ReentrantLock lock = new ReentrantLock(); + //For sake of simplicity in the pre Gamma :) + Stack getStack(); - protected DiameterProvider provider; + DiameterProvider getProvider(); - // ===== STACK MANAGEMENT ===== + DiameterMessageFactory getMessageFactory(); - private void initStack() throws Exception { - initStack(this.getClass().getClassLoader().getResourceAsStream("config/jdiameter-config.xml")); - } + DiameterStackMultiplexerAS7 getMultiplexerMBean(); - private void initStack(InputStream is) throws Exception { - try { - // Create and configure stack - this.stack = new StackImpl(); + // MANAGEMENT OPERATIONS - // Load the configuration - Configuration config = new XMLConfiguration(is); - - this.stack.init(config); + // Get a Serializable Configuration - Network network = stack.unwrap(Network.class); + DiameterConfiguration getDiameterConfiguration(); - Set appIds = stack.getMetaData().getLocalPeer().getCommonApplications(); + // Local Peer ---------------------------------------------------------- - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: Supporting {} applications.", appIds.size()); - } - //network.addNetworkReqListener(this, ApplicationId.createByAccAppId(193, 19302)); - - for (org.jdiameter.api.ApplicationId appId : appIds) { - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: Adding Listener for [{}].", appId); - } - network.addNetworkReqListener(this, appId); + /** + * Changes the URI of the Local Peer. + * + * @param uri the new URI to be used by the Local Peer + */ + void _LocalPeer_setURI(String uri); - if (appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { - this.appIdToListener.put(appId.getAcctAppId(), null); - } - else if (appId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { - this.appIdToListener.put(appId.getAuthAppId(), null); - } - } + /** + * Adds an IP Address to the Local Peer. + * @param ipAddress the IP Address to be added, if not present + */ + void _LocalPeer_addIPAddress(String ipAddress); - try { - if (logger.isInfoEnabled()) { - logger.info("Parsing AVP Dictionary file..."); - } - AvpDictionary.INSTANCE.parseDictionary(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary.xml")); - if (logger.isInfoEnabled()) { - logger.info("AVP Dictionary file successfuly parsed!"); - } - } - catch (Exception e) { - logger.error("Error while parsing dictionary file.", e); - } - - this.stack.start(); - } - finally { - if (is != null) { - is.close(); - } - - is = null; - } - - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: Successfully initialized stack."); - } - } - - private void doStopStack(int disconnectCause) throws Exception { - try { - if (logger.isInfoEnabled()) { - logger.info("Stopping Diameter Mux Stack..."); - } - - stack.stop(10, TimeUnit.SECONDS, disconnectCause); - - if (logger.isInfoEnabled()) { - logger.info("Diameter Mux Stack Stopped Successfully."); - } - } - catch (Exception e) { - logger.error("Failure while stopping stack", e); - } - - stack.destroy(); - } - - private DiameterListener findListener(Message message) { - List appIds = message.getApplicationIdAvps(); - - if (appIds.size() > 0) { - for (org.jdiameter.api.ApplicationId appId : appIds) { - if (logger.isDebugEnabled()) { - logger.debug("Diameter Stack Mux :: findListener :: AVP AppId [" + appId + "]"); - } - - DiameterListener listener; - - Long appIdValue = appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE ? appId.getAcctAppId() : appId.getAuthAppId(); - - if ((listener = this.appIdToListener.get(appIdValue)) != null) { - if (logger.isDebugEnabled()) { - logger.debug("Diameter Stack Mux :: findListener :: Found Listener [" + listener + "]"); - } - - return listener; - } - } - } - else { - Long appId = message.getApplicationId(); - - if (logger.isDebugEnabled()) { - logger.debug("Diameter Stack Mux :: findListener :: Header AppId [" + appId + "]"); - } - - DiameterListener listener; - - if ((listener = this.appIdToListener.get(appId)) != null) { - if (logger.isDebugEnabled()) { - logger.debug("Diameter Stack Mux :: findListener :: Found Listener [" + listener + "]"); - } - - return listener; - } - } - - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: findListener :: No Listener Found."); - } - - return null; - } - - // ===== NetworkReqListener IMPLEMENTATION ===== - - @Override - public Answer processRequest(Request request) { - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: processRequest :: Command-Code [" + request.getCommandCode() + "]"); - } - - DiameterListener listener = findListener(request); - - if (listener != null) { - return listener.processRequest(request); - } - else { - try { - Answer answer = request.createAnswer(ResultCode.APPLICATION_UNSUPPORTED); - //this.stack.getSessionFactory().getNewRawSession().send(answer); - return answer; - } - catch (Exception e) { - logger.error("Failed to create APPLICATION UNSUPPORTED answer.", e); - } - } - return null; - } - - // ===== EventListener IMPLEMENTATION ===== - - @Override - public void receivedSuccessMessage(Request request, Answer answer) { - DiameterListener listener = findListener(request); - - if (listener != null) { - listener.receivedSuccessMessage(request, answer); - } - } - - @Override - public void timeoutExpired(Request request) { - DiameterListener listener = findListener(request); - - if (listener != null) { - listener.timeoutExpired(request); - } - } - - // ===== SERVICE LIFECYCLE MANAGEMENT ===== - - public void startService() { //throws Exception { - try { - logger.debug("startService"); - initStack(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void stopService() { // throws Exception { - try { - doStopStack(DisconnectCause.REBOOTING); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public String sendMessage(Message message) { - try { - Avp sessionId = null; - Session session = null; - - if ((sessionId = message.getAvps().getAvp(Avp.SESSION_ID)) == null) { - session = stack.getSessionFactory().getNewSession(); - } - else { - session = stack.getSessionFactory().getNewSession(sessionId.getUTF8String()); - } - - session.send(message); - - return session.getSessionId(); - } - catch (Exception e) { - logger.error("", e); - } - - return null; - } - - @Override - public Message sendMessageSync(Message message) { - try { - Avp sessionId = null; - Session session = null; - - if ((sessionId = message.getAvps().getAvp(Avp.SESSION_ID)) == null) { - session = stack.getSessionFactory().getNewSession(); - } - else { - session = stack.getSessionFactory().getNewSession(sessionId.getUTF8String()); - } - - Future answer = session.send(message); - - return answer.get(); - } - catch (Exception e) { - logger.error("", e); - } - - return null; - } - - @Override - public Message createMessage(boolean isRequest, int commandCode, long applicationId) { - try { - Message message = this.stack.getSessionFactory().getNewRawSession(). - createMessage(commandCode, org.jdiameter.api.ApplicationId.createByAccAppId(applicationId), new Avp[]{}); - message.setRequest(isRequest); - - return message; - } - catch (Exception e) { - logger.error("Failure while creating message.", e); - } - - return null; - } - - @Override - public Message createRequest(int commandCode, long applicationId) { - return createMessage(true, commandCode, applicationId); - } - - @Override - public Message createAnswer(int commandCode, long applicationId) { - return createMessage(false, commandCode, applicationId); - } - - // ===== MBEAN OPERATIONS ===== - - @Override - public DiameterStackMultiplexerAS7MBean getMultiplexerMBean() { - return (DiameterStackMultiplexerAS7MBean)this; - } - - @Override - public DiameterMessageFactory getMessageFactory() { - return this; - } - - @Override - public DiameterProvider getProvider() { - return this; - } - - @Override - public Stack getStack() { - return new DiameterStackProxy(this.stack); - } - - @Override - public void registerListener(DiameterListener listener, org.jdiameter.api.ApplicationId[] appIds) throws IllegalStateException { - if (listener == null) { - logger.warn("Trying to register a null Listener. Give up..."); - return; - } - - int curAppIdIndex = 0; - - try { - lock.lock(); - - // Register the selected appIds in the stack - Network network = stack.unwrap(Network.class); - - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: Registering " + appIds.length + " applications."); - } - - for (; curAppIdIndex < appIds.length; curAppIdIndex++) { - org.jdiameter.api.ApplicationId appId = appIds[curAppIdIndex]; - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: Adding Listener for [" + appId + "]."); - } - network.addNetworkReqListener(this, appId); - - if (appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { - this.appIdToListener.put(appId.getAcctAppId(), listener); - } - else if (appId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { - this.appIdToListener.put(appId.getAuthAppId(), listener); - } - } - - // And add the listener and it's holder - Collection registeredAppIds = this.listenerToAppId.get(listener); - - // Merge the existing (if any) with new. - if (registeredAppIds != null) { - registeredAppIds.addAll(Arrays.asList(appIds)); - } - else { - this.listenerToAppId.put(listener, Arrays.asList(appIds)); - } - } - catch (ApplicationAlreadyUseException aaue) { - // Let's remove what we've done so far... - try { - Network network = stack.unwrap(Network.class); - - for (; curAppIdIndex >= 0; curAppIdIndex--) { - ApplicationId appId = appIds[curAppIdIndex]; - Long appIdValue = appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE ? appId.getAcctAppId() : appId.getAuthAppId(); - - // Remove the app id from map - this.appIdToListener.remove(appIdValue); - - // Unregister it from stack listener - network.removeNetworkReqListener(appId); - } - } - catch (Exception e) { - logger.error("", e); - } - } - catch (Exception e) { - logger.error("", e); - } - finally { - lock.unlock(); - } - } - - @Override - public void unregisterListener(DiameterListener listener) { - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: unregisterListener :: Listener [" + listener + "]"); - } - - if (listener == null) { - logger.warn("Diameter Stack Mux :: unregisterListener :: Trying to unregister a null Listener. Give up..."); - return; - } - - try { - lock.lock(); - - Collection appIds = this.listenerToAppId.remove(listener); - - if (appIds == null) { - logger.warn("Diameter Stack Mux :: unregisterListener :: Listener has no App-Ids registered. Give up..."); - return; - } - - Network network = stack.unwrap(Network.class); - - for (org.jdiameter.api.ApplicationId appId : appIds) { - try { - if (logger.isInfoEnabled()) { - logger.info("Diameter Stack Mux :: unregisterListener :: Unregistering AppId [" + appId + "]"); - } - - Long appIdValue = appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE ? appId.getAcctAppId() : appId.getAuthAppId(); - - // Remove the appid from map - this.appIdToListener.remove(appIdValue); - - // and unregister the listener from stack - network.removeNetworkReqListener(appId); - } - catch (Exception e) { - logger.error("", e); - } - } - } - catch (InternalException ie) { - logger.error("", ie); - } - finally { - lock.unlock(); - } - } - - // management operations ---------------------------------------------- - - /* - * -- MutableConfiguration Parameters -- - * Levels Parameters name - * Runtime - * y DuplicateTimer - * y AcceptUndefinedPeer - * y MessageTimeOut - * y StopTimeOut - * y CeaTimeOut - * y IacTimeOut - * y DwaTimeOut - * y DpaTimeOut - * y RecTimeOut - * y PeerTable, Peer, PeerName, PeerRating, PeerAttemptConnection (by NetWork interface) - * y RealmTable, Realm, RealmEntry RealmName, RealmHosts, RealmLocalAction, RealmEntryIsDynamic, RealmEntryExpTime (by NetWork interface) - * Restart stack - * y OwnDiameterURI - * y OwnIPAddresses, OwnIPAddress - * y OwnRealm - * y OwnVendorID - * n OwnProductName - * n OwnFirmwareRevision - * n ApplicationId, VendorId, AuthApplId, AcctApplId - * Not changeable - * n OverloadMonitor, OverloadMonitorEntry, OverloadMonitorData, OverloadEntryIndex, OverloadEntryhighThreshold, OverloadEntrylowThreshold - * n DuplicateProtection - * n QueueSize + /** + * Removes an IP Address from the Local Peer. + * + * @param ipAddress the IP Address to be removed, if present */ + void _LocalPeer_removeIPAddress(String ipAddress); - private final String DEFAULT_STRING = "default_string"; + /** + * Changes the Realm of the Local Peer. + * + * @param realm the new Realm to be used by the Local Peer + */ + void _LocalPeer_setRealm(String realm); - private MutableConfiguration getMutableConfiguration() { - return (MutableConfiguration) stack.getMetaData().getConfiguration(); - } + /** + * Sets the Local Peer Vendor-Id. + * + * @param vendorId the new Vendor-Id for the Peer + */ + void _LocalPeer_setVendorId(long vendorId); - private AppConfiguration getClientConfiguration() { - return org.jdiameter.client.impl.helpers.EmptyConfiguration.getInstance(); - } + // Parameters ---------------------------------------------------------- - final Pattern IP_PATTERN = Pattern.compile("\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" - + "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); + /** + * Sets whether the stack will accept connections from unknown peers or not (default: true) + * + * @param acceptUndefinedPeer indicates if the stack will accept unknown connections + */ + void _Parameters_setAcceptUndefinedPeer(boolean acceptUndefinedPeer); - @Override - public void _LocalPeer_addIPAddress(String ipAddress) { - // validate ip address - if (IP_PATTERN.matcher(ipAddress).matches()) { - Configuration[] oldIPAddressesConfig = getMutableConfiguration().getChildren(OwnIPAddresses.ordinal()); + /** + * Sets whether the stack will use URI (aaa://IP_ADDRESS:PORT) as FQDN. Some Peers require it. + * + * @param useUriAsFqdn indicates if the stack will use URI as FQDN + */ + void _Parameters_setUseUriAsFqdn(boolean useUriAsFqdn); - List newIPAddressesConfig = Arrays.asList(oldIPAddressesConfig); - AppConfiguration newIPAddress = getClientConfiguration().add(OwnIPAddress, ipAddress); - newIPAddressesConfig.add(newIPAddress); + /** + * Sets the value to consider a message as a duplicate, in ms. (default: 240000, 4 minutes). + * + * @param duplicateTimer the amount of time, in ms. + */ + void _Parameters_setDuplicateTimer(long duplicateTimer); - getMutableConfiguration().setChildren(OwnIPAddresses.ordinal(), (Configuration[]) newIPAddressesConfig.toArray()); + // Parameters : Timeouts ----------------------------------------------- - if (logger.isInfoEnabled()) { - logger.info("Local Peer IP Address successfully changed to " + ipAddress + ". Restart to Diameter stack is needed to apply changes."); - } - } - else { - throw new RuntimeException(new IllegalArgumentException("Invalid IP address entered (" + ipAddress + ")")); - } - } + /** + * Sets the timeout for general Diameter messages, in ms. (default: 60000, 1 minute). + * + * @param messageTimeout the amount of time, in ms. + */ + void _Parameters_setMessageTimeout(long messageTimeout); - /* - * (non-Javadoc) - * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_removeIPAddress(java.lang.String) + /** + * Sets the timeout for stopping the stack. (default: 10000, 10 seconds). + * + * @param stopTimeout the amount of time, in ms. */ - @Override - public void _LocalPeer_removeIPAddress(String ipAddress) { - Configuration[] oldIPAddressesConfig = getMutableConfiguration().getChildren(OwnIPAddresses.ordinal()); - - Configuration ipAddressToRemove = null; - - List newIPAddressesConfig = Arrays.asList(oldIPAddressesConfig); - for (Configuration curIPAddress : newIPAddressesConfig) { - if (curIPAddress.getStringValue(OwnIPAddress.ordinal(), DEFAULT_STRING).equals(ipAddress)) { - ipAddressToRemove = curIPAddress; - break; - } - } - - if (ipAddressToRemove != null) { - newIPAddressesConfig.remove(ipAddressToRemove); - - getMutableConfiguration().setChildren(OwnIPAddresses.ordinal(), (Configuration[]) newIPAddressesConfig.toArray()); - - if (logger.isInfoEnabled()) { - logger.info("Local Peer IP Address " + ipAddress + " successfully added. Restart to Diameter stack is needed to apply changes."); - } - } - else { - if (logger.isInfoEnabled()) { - logger.info("Local Peer IP Address " + ipAddress + " not found. No changes were made."); - } - } - } - - /* - * (non-Javadoc) - * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_setRealm(java.lang.String) + void _Parameters_setStopTimeout(long stopTimeout); + + /** + * Sets the timeout for CEA messages. (default: 10000, 10 seconds). + * + * @param ceaTimeout the amount of time, in ms. */ - @Override - public void _LocalPeer_setRealm(String realm) { - getMutableConfiguration().setStringValue(OwnRealm.ordinal(), realm); - - if (logger.isInfoEnabled()) { - logger.info("Local Peer Realm successfully changed to '" + realm + "'. Restart to Diameter stack is needed to apply changes."); - } - } - - /* - * (non-Javadoc) - * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_setURI(java.lang.String) + void _Parameters_setCeaTimeout(long ceaTimeout); + + /** + * Sets the timeout for inactiveness. (default: 20000, 20 seconds). + * + * @param iacTimeout the amount of time, in ms. */ - @Override - public void _LocalPeer_setURI(String uri) { - // validate uri - try { - new URI(uri); - - getMutableConfiguration().setStringValue(OwnDiameterURI.ordinal(), uri); - - if (logger.isInfoEnabled()) { - logger.info("Local Peer URI successfully changed to '" + uri + "'. Restart to Diameter stack is needed to apply changes."); - } - } - catch (URISyntaxException use) { - throw new RuntimeException(use); - } - } - - /* - * (non-Javadoc) - * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_setVendorId(java.lang.String) + void _Parameters_setIacTimeout(long iacTimeout); + + /** + * Sets the timeout for DWA messages. (default: 10000, 10 seconds). + * + * @param dwaTimeout the amount of time, in ms. */ - @Override - public void _LocalPeer_setVendorId(long vendorId) { - // validate vendor-id - try { - getMutableConfiguration().setLongValue(OwnVendorID.ordinal(), vendorId); - if (logger.isInfoEnabled()) { - logger.info("Local Peer Vendor-Id successfully changed to '" + vendorId + "'. Restart to Diameter stack is needed to apply changes."); - } - } - catch (NumberFormatException nfe) { - throw new RuntimeException(nfe); - } - } - - /* - * (non-Javadoc) - * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_Network_Peers_addPeer(java.lang.String, boolean, int, String) + void _Parameters_setDwaTimeout(long dwaTimeout); + + /** + * Sets the timeout for DPA messages. (default: 5000, 5 seconds). + * + * @param dpaTimeout the amount of time, in ms. */ - @Override - public void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating, String realm) { - try { - NetworkImpl n = (NetworkImpl) stack.unwrap(Network.class); - /*Peer p =*/ n.addPeer(name, realm, attemptConnect); - } - catch (IllegalArgumentException e) { - logger.warn(e.getMessage()); - } - catch (InternalException e) { - throw new RuntimeException("Failed to add peer with name '" + name + "'", e); - } - } - - /* - * (non-Javadoc) - * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_Network_Peers_removePeer(java.lang.String) + void _Parameters_setDpaTimeout(long dpaTimeout); + + /** + * Sets the timeout for reconnecting. (default: 10000, 10 seconds). + * + * @param recTimeout the amount of time, in ms. + */ + void _Parameters_setRecTimeout(long recTimeout); + + void _Parameters_setConcurrentEntity(String name, String desc, Integer size); + + void _Parameters_setStatisticLoggerDelay(long delay); + + void _Parameters_setStatisticLoggerPause(long pause); + + // Network : Peers ----------------------------------------------------- + + /** + * Adds a peer definition to the stack. Same as element in XML Configuration. + * + * @param name the name/uri of the peer + * @param attemptConnect indicates if the stack should try to connect to this peer or wait for incoming connection + * @param rating the peer rating for decision on message routing + */ + void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating); + + /** + * Removes a peer definition from stack. + * + * @param name the name/uri of the peer + */ + void _Network_Peers_removePeer(String name); + + // Network : Realms ---------------------------------------------------- + + /** + * Adds a new Realm to the stack. Same as element in XML Configuration. + * + * @param name the name of the Realm + * @param peers the Realm peer hosts, separated by comma + * @param appVendorId the vendor-id of the application supported by this realm + * @param appAcctId the accounting-id of the application supported by this realm + * @param appAuthId the authorization-id of the application supported by this realm + */ + void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId); + + void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId, String localAction, String agentConfiguration, + boolean isDynamic, int expTime); + + /** + * Removes a Realm from the stack. + * + * @param name the name of the Realm */ - @Override - public void _Network_Peers_removePeer(String name) { - try { - MutablePeerTable n = (MutablePeerTable) stack.unwrap(PeerTable.class); - n.removePeer(name); - } - catch (InternalException e) { - throw new RuntimeException("Failed to remove peer with name '" + name + "'", e); - } - } - - @Override - public void _Network_Realms_addPeerToRealm(String realmName, String peerName, boolean attemptConnect) { - try { - NetworkImpl n = (NetworkImpl) stack.unwrap(Network.class); - /*Peer p =*/ n.addPeer(peerName, realmName, attemptConnect); - } - catch (IllegalArgumentException e) { - logger.warn(e.getMessage()); - } - catch (InternalException e) { - throw new RuntimeException("Failed to add peer with name '" + peerName + "' to realm '" + realmName + "'", e); - } - } - - @Override - public void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId, String localAction, - String agentConfiguration, boolean isDynamic, int expTime) { - try { - org.jdiameter.server.impl.NetworkImpl n = (org.jdiameter.server.impl.NetworkImpl) stack.unwrap(org.jdiameter.api.Network.class); - ApplicationId appId = appAcctId == 0 ? org.jdiameter.api.ApplicationId.createByAuthAppId(appVendorId, appAuthId) : - org.jdiameter.api.ApplicationId.createByAccAppId(appVendorId, appAcctId); - org.jdiameter.api.Realm r = n.addRealm(name, appId, LocalAction.valueOf(localAction), agentConfiguration, isDynamic, expTime); - for (String peer : peers.split(",")) { - ((IRealm) r).addPeerName(peer); - } - } - catch (InternalException e) { - throw new RuntimeException("Failed to add realm with name '" + name + "'.", e); - } - } - - @Override - public void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId) { - _Network_Realms_addRealm(name, peers, appVendorId, appAcctId, appAuthId, "LOCAL", null, false, 1); - } - - @Override - public void _Network_Realms_removePeerFromRealm(String realmName, String peerName) { - try { - IRealmTable rt = stack.unwrap(IRealmTable.class); - for (org.jdiameter.api.Realm r : rt.getRealms()) { - if (r.getName().equals(realmName)) { - ((IRealm) r).removePeerName(peerName); - } - } - } - catch (InternalException e) { - throw new RuntimeException("Failed to add peer '" + peerName + "' from realm with '" + realmName + "'.", e); - } - } - - @Override - public void _Network_Realms_removeRealm(String name) { - try { - org.jdiameter.server.impl.NetworkImpl n = (org.jdiameter.server.impl.NetworkImpl) stack.unwrap(org.jdiameter.api.Network.class); - n.remRealm(name); - } - catch (InternalException e) { - throw new RuntimeException("Failed to remove realm '" + name + "'.", e); - } - } - - @Override - public void _Parameters_setAcceptUndefinedPeer(boolean acceptUndefinedPeer) { - getMutableConfiguration().setBooleanValue(AcceptUndefinedPeer.ordinal(), acceptUndefinedPeer); - } - - @Override - public void _Parameters_setUseUriAsFqdn(boolean useUriAsFqdn) { - getMutableConfiguration().setBooleanValue(UseUriAsFqdn.ordinal(), useUriAsFqdn); - } - - @Override - public void _Parameters_setDuplicateTimer(long duplicateTimer) { - getMutableConfiguration().setLongValue(DuplicateTimer.ordinal(), duplicateTimer); - } - - @Override - public void _Parameters_setMessageTimeout(long messageTimeout) { - getMutableConfiguration().setLongValue(MessageTimeOut.ordinal(), messageTimeout); - } - - @Override - public void _Parameters_setStopTimeout(long stopTimeout) { - getMutableConfiguration().setLongValue(StopTimeOut.ordinal(), stopTimeout); - } - - @Override - public void _Parameters_setCeaTimeout(long stopTimeout) { - getMutableConfiguration().setLongValue(CeaTimeOut.ordinal(), stopTimeout); - } - - @Override - public void _Parameters_setIacTimeout(long stopTimeout) { - getMutableConfiguration().setLongValue(IacTimeOut.ordinal(), stopTimeout); - } - - @Override - public void _Parameters_setDwaTimeout(long stopTimeout) { - getMutableConfiguration().setLongValue(DwaTimeOut.ordinal(), stopTimeout); - } - - @Override - public void _Parameters_setDpaTimeout(long stopTimeout) { - getMutableConfiguration().setLongValue(DpaTimeOut.ordinal(), stopTimeout); - } - - @Override - public void _Parameters_setRecTimeout(long stopTimeout) { - getMutableConfiguration().setLongValue(RecTimeOut.ordinal(), stopTimeout); - } - - @Override - public void _Parameters_setConcurrentEntity(String name, String desc, Integer size) { - for (Configuration c : getMutableConfiguration().getChildren(Concurrent.ordinal())) { - if (name.equals(c.getStringValue(ConcurrentEntityName.ordinal(), null))) { - ((AppConfiguration) c).add(ConcurrentEntityPoolSize, size); - if (desc != null) { - ((AppConfiguration) c).add(ConcurrentEntityDescription, desc); - } - } - } - } - @Override - public void _Parameters_setStatisticLoggerDelay(long delay) { - getMutableConfiguration().setLongValue(StatisticsLoggerDelay.ordinal(), delay); - } - - @Override - public void _Parameters_setStatisticLoggerPause(long pause) { - getMutableConfiguration().setLongValue(StatisticsLoggerPause.ordinal(), pause); - } - - @Override - public void _Validation_setEnabled(boolean enableValidation) { - ((DictionaryImpl) DictionarySingleton.getDictionary()).setEnabled(enableValidation) ; - } - - @Override - public String dumpStackConfiguration() { - return getMutableConfiguration().toString(); - } - - @Override - public void startStack() { - try { - this.stack.start(); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public void stopStack(int disconnectCause) { - try { - this.stack.stop(getMutableConfiguration().getLongValue(StopTimeOut.ordinal(), 10000L), TimeUnit.MILLISECONDS, disconnectCause); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - - // Getters ------------------------------------------------------------- // - - @Override - public String _LocalPeer_getProductName() { - return this.stack.getMetaData().getLocalPeer().getProductName(); - } - - @Override - public Long _LocalPeer_getVendorId() { - return this.stack.getMetaData().getLocalPeer().getVendorId(); - } - - @Override - public Long _LocalPeer_getFirmware() { - return this.stack.getMetaData().getLocalPeer().getFirmware(); - } - - @Override - public String _LocalPeer_getURI() { - return this.stack.getMetaData().getLocalPeer().getUri().toString(); - } - - @Override - public String _LocalPeer_getRealmName() { - return this.stack.getMetaData().getLocalPeer().getRealmName(); - } - - @Override - public InetAddress[] _LocalPeer_getIPAddresses() { - return this.stack.getMetaData().getLocalPeer().getIPAddresses(); - } - - @Override - public Set _LocalPeer_getCommonApplicationIds() { - return this.stack.getMetaData().getLocalPeer().getCommonApplications(); - } - - @Override - public String[] _Network_Realms_getRealms() { - Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); - String[] realmNames = new String[realmEntries.length]; - - for (int i = 0; i < realmEntries.length; i++) { - realmNames[i] = realmEntries[i].getStringValue(RealmName.ordinal(), DEFAULT_STRING); - } - - return realmNames; - } - - @Override - public String[] _Network_Realms_getRealmPeers(String realmName) { - Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); - String[] realmHosts = new String[realmEntries.length]; - - for (Configuration realmEntry : realmEntries) { - if (realmEntry.getStringValue(RealmName.ordinal(), DEFAULT_STRING).equals(realmName)) { - - String realmHostsString = realmEntry.getStringValue(RealmHosts.ordinal(), DEFAULT_STRING); - if (!realmHostsString.equals(DEFAULT_STRING)) { - realmHosts = realmHostsString.replaceAll(" ", "").split(","); - } - } - } - - return realmHosts; - } - - @Override - public DiameterConfiguration getDiameterConfiguration() { - return new DiameterConfiguration(stack); - } - - @Override - public boolean _LocalPeer_isActive() { - return this.stack.isActive(); - } - - @Override - public boolean _Network_Peers_isPeerConnected(String name) { - try { - MutablePeerTable n = (MutablePeerTable) stack.unwrap(PeerTable.class); - PeerImpl p = ((PeerImpl) n.getPeer(name)); - return p != null ? p.getContext().isConnected() : false; - } - catch (Exception e) { - throw new RuntimeException("Failed to get connection availability for peer with name '" + "'.", e); - } - } + void _Network_Realms_removeRealm(String name); + + /** + * Adds a new Peer host to the Realm + * + * @param realmName the name of the Realm + * @param peerName the name/host of the Peer to be added + * @param attemptConnecting either try or not to connect the peer (client/server) + */ + void _Network_Realms_addPeerToRealm(String realmName, String peerName, boolean attemptConnecting); + + /** + * Removes a Peer host from the Realm + * + * @param realmName the name of the Realm + * @param peerName the name/host of the Peer to be removed + */ + void _Network_Realms_removePeerFromRealm(String realmName, String peerName); + + // Stack Operation ----------------------------------------------------- + + /** + * Operation to stop the stack. + * + */ + void stopStack(int disconnectCause); + + /** + * Operation to start the stack. + * + */ + void startStack(); + + // Validation ---------------------------------------------------------- + + /** + * Sets whether validation on Diameter messages/AVPs should be performed or not. + * + * @param enableValidation flag indicating if validation should be performed + */ + void _Validation_setEnabled(boolean enableValidation); + + // Configuration Dump -------------------------------------------------- + + /** + * Dumps full stack configuration. + * + * @return a String with stack configuration + */ + String dumpStackConfiguration(); + + // Information dump methods -------------------------------------------- + + String _LocalPeer_getProductName(); + + Long _LocalPeer_getVendorId(); + + Long _LocalPeer_getFirmware(); + + String _LocalPeer_getURI(); + + String _LocalPeer_getRealmName(); + + InetAddress[] _LocalPeer_getIPAddresses(); + + Set _LocalPeer_getCommonApplicationIds(); + + String[] _Network_Realms_getRealms(); + + String[] _Network_Realms_getRealmPeers(String realmName); + + boolean _LocalPeer_isActive(); + + boolean _Network_Peers_isPeerConnected(String name); } diff --git a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7Bean.java b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7Bean.java new file mode 100644 index 000000000..1666e5f49 --- /dev/null +++ b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7Bean.java @@ -0,0 +1,970 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2015, Telestax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + */ + +package org.mobicents.diameter.stack; + +import static org.jdiameter.client.impl.helpers.Parameters.CeaTimeOut; +import static org.jdiameter.client.impl.helpers.Parameters.Concurrent; +import static org.jdiameter.client.impl.helpers.Parameters.ConcurrentEntityDescription; +import static org.jdiameter.client.impl.helpers.Parameters.ConcurrentEntityName; +import static org.jdiameter.client.impl.helpers.Parameters.ConcurrentEntityPoolSize; +import static org.jdiameter.client.impl.helpers.Parameters.DpaTimeOut; +import static org.jdiameter.client.impl.helpers.Parameters.DwaTimeOut; +import static org.jdiameter.client.impl.helpers.Parameters.IacTimeOut; +import static org.jdiameter.client.impl.helpers.Parameters.MessageTimeOut; +import static org.jdiameter.client.impl.helpers.Parameters.OwnDiameterURI; +import static org.jdiameter.client.impl.helpers.Parameters.OwnIPAddress; +import static org.jdiameter.client.impl.helpers.Parameters.OwnRealm; +import static org.jdiameter.client.impl.helpers.Parameters.OwnVendorID; +import static org.jdiameter.client.impl.helpers.Parameters.RealmEntry; +import static org.jdiameter.client.impl.helpers.Parameters.RealmTable; +import static org.jdiameter.client.impl.helpers.Parameters.RecTimeOut; +import static org.jdiameter.client.impl.helpers.Parameters.StatisticsLoggerDelay; +import static org.jdiameter.client.impl.helpers.Parameters.StatisticsLoggerPause; +import static org.jdiameter.client.impl.helpers.Parameters.StopTimeOut; +import static org.jdiameter.client.impl.helpers.Parameters.UseUriAsFqdn; +import static org.jdiameter.server.impl.helpers.Parameters.AcceptUndefinedPeer; +import static org.jdiameter.server.impl.helpers.Parameters.DuplicateTimer; +import static org.jdiameter.server.impl.helpers.Parameters.OwnIPAddresses; +import static org.jdiameter.server.impl.helpers.Parameters.RealmHosts; +import static org.jdiameter.server.impl.helpers.Parameters.RealmName; + +import java.io.InputStream; +import java.net.InetAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.ReentrantLock; +import java.util.regex.Pattern; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ejb.Singleton; +import javax.ejb.Startup; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.ApplicationAlreadyUseException; +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.Avp; +import org.jdiameter.api.Configuration; +import org.jdiameter.api.DisconnectCause; +import org.jdiameter.api.EventListener; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.LocalAction; +import org.jdiameter.api.Message; +import org.jdiameter.api.MutableConfiguration; +import org.jdiameter.api.MutablePeerTable; +import org.jdiameter.api.Network; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.PeerTable; +import org.jdiameter.api.Request; +import org.jdiameter.api.ResultCode; +import org.jdiameter.api.Session; +import org.jdiameter.api.Stack; +import org.jdiameter.client.api.controller.IRealm; +import org.jdiameter.client.api.controller.IRealmTable; +import org.jdiameter.client.impl.DictionarySingleton; +import org.jdiameter.client.impl.controller.PeerImpl; +import org.jdiameter.client.impl.helpers.AppConfiguration; +import org.jdiameter.common.impl.validation.DictionaryImpl; +import org.jdiameter.server.impl.NetworkImpl; +import org.jdiameter.server.impl.StackImpl; +import org.jdiameter.server.impl.helpers.XMLConfiguration; +import org.mobicents.diameter.api.DiameterMessageFactory; +import org.mobicents.diameter.api.DiameterProvider; +import org.mobicents.diameter.dictionary.AvpDictionary; +import org.mobicents.diameter.stack.management.DiameterConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Alexandre Mendonca + */ +@Startup +@Singleton(name = "mux") +public class DiameterStackMultiplexerAS7Bean implements DiameterStackMultiplexerAS7, DiameterProvider, NetworkReqListener, EventListener, + DiameterMessageFactory { + + private static final Logger logger = LoggerFactory.getLogger(DiameterStackMultiplexerAS7Bean.class); + + protected Stack stack = null; + + protected HashMap> listenerToAppId = + new HashMap>(3); + protected HashMap appIdToListener = new HashMap(3); + + // This is for synch + protected ReentrantLock lock = new ReentrantLock(); + + protected DiameterProvider provider; + + // ===== STACK MANAGEMENT ===== + + private void initStack() throws Exception { + initStack(this.getClass().getClassLoader().getResourceAsStream("config/jdiameter-config.xml")); + } + + private void initStack(InputStream is) throws Exception { + try { + // Create and configure stack + this.stack = new StackImpl(); + + // Load the configuration + Configuration config = new XMLConfiguration(is); + + this.stack.init(config); + + Network network = stack.unwrap(Network.class); + + Set appIds = stack.getMetaData().getLocalPeer().getCommonApplications(); + + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: Supporting {} applications.", appIds.size()); + } + //network.addNetworkReqListener(this, ApplicationId.createByAccAppId(193, 19302)); + + for (org.jdiameter.api.ApplicationId appId : appIds) { + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: Adding Listener for [{}].", appId); + } + network.addNetworkReqListener(this, appId); + + if (appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { + this.appIdToListener.put(appId.getAcctAppId(), null); + } + else if (appId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { + this.appIdToListener.put(appId.getAuthAppId(), null); + } + } + + try { + if (logger.isInfoEnabled()) { + logger.info("Parsing AVP Dictionary file..."); + } + AvpDictionary.INSTANCE.parseDictionary(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary.xml")); + if (logger.isInfoEnabled()) { + logger.info("AVP Dictionary file successfuly parsed!"); + } + } + catch (Exception e) { + logger.error("Error while parsing dictionary file.", e); + } + + this.stack.start(); + } + finally { + if (is != null) { + is.close(); + } + + is = null; + } + + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: Successfully initialized stack."); + } + } + + private void doStopStack(int disconnectCause) throws Exception { + try { + if (logger.isInfoEnabled()) { + logger.info("Stopping Diameter Mux Stack..."); + } + + stack.stop(10, TimeUnit.SECONDS, disconnectCause); + + if (logger.isInfoEnabled()) { + logger.info("Diameter Mux Stack Stopped Successfully."); + } + } + catch (Exception e) { + logger.error("Failure while stopping stack", e); + } + + stack.destroy(); + } + + private DiameterListener findListener(Message message) { + List appIds = message.getApplicationIdAvps(); + + if (appIds.size() > 0) { + for (org.jdiameter.api.ApplicationId appId : appIds) { + if (logger.isDebugEnabled()) { + logger.debug("Diameter Stack Mux :: findListener :: AVP AppId [" + appId + "]"); + } + + DiameterListener listener; + + Long appIdValue = appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE ? appId.getAcctAppId() : appId.getAuthAppId(); + + if ((listener = this.appIdToListener.get(appIdValue)) != null) { + if (logger.isDebugEnabled()) { + logger.debug("Diameter Stack Mux :: findListener :: Found Listener [" + listener + "]"); + } + + return listener; + } + } + } + else { + Long appId = message.getApplicationId(); + + if (logger.isDebugEnabled()) { + logger.debug("Diameter Stack Mux :: findListener :: Header AppId [" + appId + "]"); + } + + DiameterListener listener; + + if ((listener = this.appIdToListener.get(appId)) != null) { + if (logger.isDebugEnabled()) { + logger.debug("Diameter Stack Mux :: findListener :: Found Listener [" + listener + "]"); + } + + return listener; + } + } + + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: findListener :: No Listener Found."); + } + + return null; + } + + // ===== NetworkReqListener IMPLEMENTATION ===== + + @Override + public Answer processRequest(Request request) { + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: processRequest :: Command-Code [" + request.getCommandCode() + "]"); + } + + DiameterListener listener = findListener(request); + + if (listener != null) { + return listener.processRequest(request); + } + else { + try { + Answer answer = request.createAnswer(ResultCode.APPLICATION_UNSUPPORTED); + //this.stack.getSessionFactory().getNewRawSession().send(answer); + return answer; + } + catch (Exception e) { + logger.error("Failed to create APPLICATION UNSUPPORTED answer.", e); + } + } + return null; + } + + // ===== EventListener IMPLEMENTATION ===== + + @Override + public void receivedSuccessMessage(Request request, Answer answer) { + DiameterListener listener = findListener(request); + + if (listener != null) { + listener.receivedSuccessMessage(request, answer); + } + } + + @Override + public void timeoutExpired(Request request) { + DiameterListener listener = findListener(request); + + if (listener != null) { + listener.timeoutExpired(request); + } + } + + // ===== SERVICE LIFECYCLE MANAGEMENT ===== + + @PostConstruct + protected void startService() throws Exception { + initStack(); + } + + @PreDestroy + protected void stopService() throws Exception { + doStopStack(DisconnectCause.REBOOTING); + } + + @Override + public String sendMessage(Message message) { + try { + Avp sessionId = null; + Session session = null; + + if ((sessionId = message.getAvps().getAvp(Avp.SESSION_ID)) == null) { + session = stack.getSessionFactory().getNewSession(); + } + else { + session = stack.getSessionFactory().getNewSession(sessionId.getUTF8String()); + } + + session.send(message); + + return session.getSessionId(); + } + catch (Exception e) { + logger.error("", e); + } + + return null; + } + + @Override + public Message sendMessageSync(Message message) { + try { + Avp sessionId = null; + Session session = null; + + if ((sessionId = message.getAvps().getAvp(Avp.SESSION_ID)) == null) { + session = stack.getSessionFactory().getNewSession(); + } + else { + session = stack.getSessionFactory().getNewSession(sessionId.getUTF8String()); + } + + Future answer = session.send(message); + + return answer.get(); + } + catch (Exception e) { + logger.error("", e); + } + + return null; + } + + @Override + public Message createMessage(boolean isRequest, int commandCode, long applicationId) { + try { + Message message = this.stack.getSessionFactory().getNewRawSession(). + createMessage(commandCode, org.jdiameter.api.ApplicationId.createByAccAppId(applicationId), new Avp[]{}); + message.setRequest(isRequest); + + return message; + } + catch (Exception e) { + logger.error("Failure while creating message.", e); + } + + return null; + } + + @Override + public Message createRequest(int commandCode, long applicationId) { + return createMessage(true, commandCode, applicationId); + } + + @Override + public Message createAnswer(int commandCode, long applicationId) { + return createMessage(false, commandCode, applicationId); + } + + // ===== MBEAN OPERATIONS ===== + + @Override + public DiameterStackMultiplexerAS7 getMultiplexerMBean() { + return this; + } + + @Override + public DiameterMessageFactory getMessageFactory() { + return this; + } + + @Override + public DiameterProvider getProvider() { + return this; + } + + @Override + public Stack getStack() { + return new DiameterStackProxy(this.stack); + } + + @Override + public void registerListener(DiameterListener listener, org.jdiameter.api.ApplicationId[] appIds) throws IllegalStateException { + if (listener == null) { + logger.warn("Trying to register a null Listener. Give up..."); + return; + } + + int curAppIdIndex = 0; + + try { + lock.lock(); + + // Register the selected appIds in the stack + Network network = stack.unwrap(Network.class); + + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: Registering " + appIds.length + " applications."); + } + + for (; curAppIdIndex < appIds.length; curAppIdIndex++) { + org.jdiameter.api.ApplicationId appId = appIds[curAppIdIndex]; + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: Adding Listener for [" + appId + "]."); + } + network.addNetworkReqListener(this, appId); + + if (appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { + this.appIdToListener.put(appId.getAcctAppId(), listener); + } + else if (appId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE) { + this.appIdToListener.put(appId.getAuthAppId(), listener); + } + } + + // And add the listener and it's holder + Collection registeredAppIds = this.listenerToAppId.get(listener); + + // Merge the existing (if any) with new. + if (registeredAppIds != null) { + registeredAppIds.addAll(Arrays.asList(appIds)); + } + else { + this.listenerToAppId.put(listener, Arrays.asList(appIds)); + } + } + catch (ApplicationAlreadyUseException aaue) { + // Let's remove what we've done so far... + try { + Network network = stack.unwrap(Network.class); + + for (; curAppIdIndex >= 0; curAppIdIndex--) { + ApplicationId appId = appIds[curAppIdIndex]; + Long appIdValue = appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE ? appId.getAcctAppId() : appId.getAuthAppId(); + + // Remove the app id from map + this.appIdToListener.remove(appIdValue); + + // Unregister it from stack listener + network.removeNetworkReqListener(appId); + } + } + catch (Exception e) { + logger.error("", e); + } + } + catch (Exception e) { + logger.error("", e); + } + finally { + lock.unlock(); + } + } + + @Override + public void unregisterListener(DiameterListener listener) { + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: unregisterListener :: Listener [" + listener + "]"); + } + + if (listener == null) { + logger.warn("Diameter Stack Mux :: unregisterListener :: Trying to unregister a null Listener. Give up..."); + return; + } + + try { + lock.lock(); + + Collection appIds = this.listenerToAppId.remove(listener); + + if (appIds == null) { + logger.warn("Diameter Stack Mux :: unregisterListener :: Listener has no App-Ids registered. Give up..."); + return; + } + + Network network = stack.unwrap(Network.class); + + for (org.jdiameter.api.ApplicationId appId : appIds) { + try { + if (logger.isInfoEnabled()) { + logger.info("Diameter Stack Mux :: unregisterListener :: Unregistering AppId [" + appId + "]"); + } + + Long appIdValue = appId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE ? appId.getAcctAppId() : appId.getAuthAppId(); + + // Remove the appid from map + this.appIdToListener.remove(appIdValue); + + // and unregister the listener from stack + network.removeNetworkReqListener(appId); + } + catch (Exception e) { + logger.error("", e); + } + } + } + catch (InternalException ie) { + logger.error("", ie); + } + finally { + lock.unlock(); + } + } + + // management operations ---------------------------------------------- + + /* + * -- MutableConfiguration Parameters -- + * Levels Parameters name + * Runtime + * y DuplicateTimer + * y AcceptUndefinedPeer + * y MessageTimeOut + * y StopTimeOut + * y CeaTimeOut + * y IacTimeOut + * y DwaTimeOut + * y DpaTimeOut + * y RecTimeOut + * y PeerTable, Peer, PeerName, PeerRating, PeerAttemptConnection (by NetWork interface) + * y RealmTable, Realm, RealmEntry RealmName, RealmHosts, RealmLocalAction, RealmEntryIsDynamic, RealmEntryExpTime (by NetWork interface) + * Restart stack + * y OwnDiameterURI + * y OwnIPAddresses, OwnIPAddress + * y OwnRealm + * y OwnVendorID + * n OwnProductName + * n OwnFirmwareRevision + * n ApplicationId, VendorId, AuthApplId, AcctApplId + * Not changeable + * n OverloadMonitor, OverloadMonitorEntry, OverloadMonitorData, OverloadEntryIndex, OverloadEntryhighThreshold, OverloadEntrylowThreshold + * n DuplicateProtection + * n QueueSize + */ + + private final String DEFAULT_STRING = "default_string"; + + private MutableConfiguration getMutableConfiguration() { + return (MutableConfiguration) stack.getMetaData().getConfiguration(); + } + + private AppConfiguration getClientConfiguration() { + return org.jdiameter.client.impl.helpers.EmptyConfiguration.getInstance(); + } + + final Pattern IP_PATTERN = Pattern.compile("\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" + + "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); + + @Override + public void _LocalPeer_addIPAddress(String ipAddress) { + // validate ip address + if (IP_PATTERN.matcher(ipAddress).matches()) { + Configuration[] oldIPAddressesConfig = getMutableConfiguration().getChildren(OwnIPAddresses.ordinal()); + + List newIPAddressesConfig = Arrays.asList(oldIPAddressesConfig); + AppConfiguration newIPAddress = getClientConfiguration().add(OwnIPAddress, ipAddress); + newIPAddressesConfig.add(newIPAddress); + + getMutableConfiguration().setChildren(OwnIPAddresses.ordinal(), (Configuration[]) newIPAddressesConfig.toArray()); + + if (logger.isInfoEnabled()) { + logger.info("Local Peer IP Address successfully changed to " + ipAddress + ". Restart to Diameter stack is needed to apply changes."); + } + } + else { + throw new RuntimeException(new IllegalArgumentException("Invalid IP address entered (" + ipAddress + ")")); + } + } + + /* + * (non-Javadoc) + * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_removeIPAddress(java.lang.String) + */ + @Override + public void _LocalPeer_removeIPAddress(String ipAddress) { + Configuration[] oldIPAddressesConfig = getMutableConfiguration().getChildren(OwnIPAddresses.ordinal()); + + Configuration ipAddressToRemove = null; + + List newIPAddressesConfig = Arrays.asList(oldIPAddressesConfig); + for (Configuration curIPAddress : newIPAddressesConfig) { + if (curIPAddress.getStringValue(OwnIPAddress.ordinal(), DEFAULT_STRING).equals(ipAddress)) { + ipAddressToRemove = curIPAddress; + break; + } + } + + if (ipAddressToRemove != null) { + newIPAddressesConfig.remove(ipAddressToRemove); + + getMutableConfiguration().setChildren(OwnIPAddresses.ordinal(), (Configuration[]) newIPAddressesConfig.toArray()); + + if (logger.isInfoEnabled()) { + logger.info("Local Peer IP Address " + ipAddress + " successfully added. Restart to Diameter stack is needed to apply changes."); + } + } + else { + if (logger.isInfoEnabled()) { + logger.info("Local Peer IP Address " + ipAddress + " not found. No changes were made."); + } + } + } + + /* + * (non-Javadoc) + * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_setRealm(java.lang.String) + */ + @Override + public void _LocalPeer_setRealm(String realm) { + getMutableConfiguration().setStringValue(OwnRealm.ordinal(), realm); + + if (logger.isInfoEnabled()) { + logger.info("Local Peer Realm successfully changed to '" + realm + "'. Restart to Diameter stack is needed to apply changes."); + } + } + + /* + * (non-Javadoc) + * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_setURI(java.lang.String) + */ + @Override + public void _LocalPeer_setURI(String uri) { + // validate uri + try { + new URI(uri); + + getMutableConfiguration().setStringValue(OwnDiameterURI.ordinal(), uri); + + if (logger.isInfoEnabled()) { + logger.info("Local Peer URI successfully changed to '" + uri + "'. Restart to Diameter stack is needed to apply changes."); + } + } + catch (URISyntaxException use) { + throw new RuntimeException(use); + } + } + + /* + * (non-Javadoc) + * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_LocalPeer_setVendorId(java.lang.String) + */ + @Override + public void _LocalPeer_setVendorId(long vendorId) { + // validate vendor-id + try { + getMutableConfiguration().setLongValue(OwnVendorID.ordinal(), vendorId); + if (logger.isInfoEnabled()) { + logger.info("Local Peer Vendor-Id successfully changed to '" + vendorId + "'. Restart to Diameter stack is needed to apply changes."); + } + } + catch (NumberFormatException nfe) { + throw new RuntimeException(nfe); + } + } + + /* + * (non-Javadoc) + * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_Network_Peers_addPeer(java.lang.String, boolean, int) + */ + @Override + public void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating) { + try { + NetworkImpl n = (NetworkImpl) stack.unwrap(Network.class); + /*Peer p =*/ n.addPeer(name, "", attemptConnect); // FIXME: This requires realm... + } + catch (IllegalArgumentException e) { + logger.warn(e.getMessage()); + } + catch (InternalException e) { + throw new RuntimeException("Failed to add peer with name '" + name + "'", e); + } + } + + /* + * (non-Javadoc) + * @see org.mobicents.diameter.stack.DiameterStackMultiplexerMBean#_Network_Peers_removePeer(java.lang.String) + */ + @Override + public void _Network_Peers_removePeer(String name) { + try { + MutablePeerTable n = (MutablePeerTable) stack.unwrap(PeerTable.class); + n.removePeer(name); + } + catch (InternalException e) { + throw new RuntimeException("Failed to remove peer with name '" + name + "'", e); + } + } + + @Override + public void _Network_Realms_addPeerToRealm(String realmName, String peerName, boolean attemptConnect) { + try { + NetworkImpl n = (NetworkImpl) stack.unwrap(Network.class); + /*Peer p =*/ n.addPeer(peerName, realmName, attemptConnect); + } + catch (IllegalArgumentException e) { + logger.warn(e.getMessage()); + } + catch (InternalException e) { + throw new RuntimeException("Failed to add peer with name '" + peerName + "' to realm '" + realmName + "'", e); + } + } + + @Override + public void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId, String localAction, + String agentConfiguration, boolean isDynamic, int expTime) { + try { + org.jdiameter.server.impl.NetworkImpl n = (org.jdiameter.server.impl.NetworkImpl) stack.unwrap(org.jdiameter.api.Network.class); + ApplicationId appId = appAcctId == 0 ? org.jdiameter.api.ApplicationId.createByAuthAppId(appVendorId, appAuthId) : + org.jdiameter.api.ApplicationId.createByAccAppId(appVendorId, appAcctId); + org.jdiameter.api.Realm r = n.addRealm(name, appId, LocalAction.valueOf(localAction), agentConfiguration, isDynamic, expTime); + for (String peer : peers.split(",")) { + ((IRealm) r).addPeerName(peer); + } + } + catch (InternalException e) { + throw new RuntimeException("Failed to add realm with name '" + name + "'.", e); + } + } + + @Override + public void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId) { + _Network_Realms_addRealm(name, peers, appVendorId, appAcctId, appAuthId, "LOCAL", null, false, 1); + } + + @Override + public void _Network_Realms_removePeerFromRealm(String realmName, String peerName) { + try { + IRealmTable rt = stack.unwrap(IRealmTable.class); + for (org.jdiameter.api.Realm r : rt.getRealms()) { + if (r.getName().equals(realmName)) { + ((IRealm) r).removePeerName(peerName); + } + } + } + catch (InternalException e) { + throw new RuntimeException("Failed to add peer '" + peerName + "' from realm with '" + realmName + "'.", e); + } + } + + @Override + public void _Network_Realms_removeRealm(String name) { + try { + org.jdiameter.server.impl.NetworkImpl n = (org.jdiameter.server.impl.NetworkImpl) stack.unwrap(org.jdiameter.api.Network.class); + n.remRealm(name); + } + catch (InternalException e) { + throw new RuntimeException("Failed to remove realm '" + name + "'.", e); + } + } + + @Override + public void _Parameters_setAcceptUndefinedPeer(boolean acceptUndefinedPeer) { + getMutableConfiguration().setBooleanValue(AcceptUndefinedPeer.ordinal(), acceptUndefinedPeer); + } + + @Override + public void _Parameters_setUseUriAsFqdn(boolean useUriAsFqdn) { + getMutableConfiguration().setBooleanValue(UseUriAsFqdn.ordinal(), useUriAsFqdn); + } + + @Override + public void _Parameters_setDuplicateTimer(long duplicateTimer) { + getMutableConfiguration().setLongValue(DuplicateTimer.ordinal(), duplicateTimer); + } + + @Override + public void _Parameters_setMessageTimeout(long messageTimeout) { + getMutableConfiguration().setLongValue(MessageTimeOut.ordinal(), messageTimeout); + } + + @Override + public void _Parameters_setStopTimeout(long stopTimeout) { + getMutableConfiguration().setLongValue(StopTimeOut.ordinal(), stopTimeout); + } + + @Override + public void _Parameters_setCeaTimeout(long stopTimeout) { + getMutableConfiguration().setLongValue(CeaTimeOut.ordinal(), stopTimeout); + } + + @Override + public void _Parameters_setIacTimeout(long stopTimeout) { + getMutableConfiguration().setLongValue(IacTimeOut.ordinal(), stopTimeout); + } + + @Override + public void _Parameters_setDwaTimeout(long stopTimeout) { + getMutableConfiguration().setLongValue(DwaTimeOut.ordinal(), stopTimeout); + } + + @Override + public void _Parameters_setDpaTimeout(long stopTimeout) { + getMutableConfiguration().setLongValue(DpaTimeOut.ordinal(), stopTimeout); + } + + @Override + public void _Parameters_setRecTimeout(long stopTimeout) { + getMutableConfiguration().setLongValue(RecTimeOut.ordinal(), stopTimeout); + } + + @Override + public void _Parameters_setConcurrentEntity(String name, String desc, Integer size) { + for (Configuration c : getMutableConfiguration().getChildren(Concurrent.ordinal())) { + if (name.equals(c.getStringValue(ConcurrentEntityName.ordinal(), null))) { + ((AppConfiguration) c).add(ConcurrentEntityPoolSize, size); + if (desc != null) { + ((AppConfiguration) c).add(ConcurrentEntityDescription, desc); + } + } + } + } + @Override + public void _Parameters_setStatisticLoggerDelay(long delay) { + getMutableConfiguration().setLongValue(StatisticsLoggerDelay.ordinal(), delay); + } + + @Override + public void _Parameters_setStatisticLoggerPause(long pause) { + getMutableConfiguration().setLongValue(StatisticsLoggerPause.ordinal(), pause); + } + + @Override + public void _Validation_setEnabled(boolean enableValidation) { + ((DictionaryImpl) DictionarySingleton.getDictionary()).setEnabled(enableValidation) ; + } + + @Override + public String dumpStackConfiguration() { + return getMutableConfiguration().toString(); + } + + @Override + public void startStack() { + try { + this.stack.start(); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void stopStack(int disconnectCause) { + try { + this.stack.stop(getMutableConfiguration().getLongValue(StopTimeOut.ordinal(), 10000L), TimeUnit.MILLISECONDS, disconnectCause); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + // Getters ------------------------------------------------------------- // + + @Override + public String _LocalPeer_getProductName() { + return this.stack.getMetaData().getLocalPeer().getProductName(); + } + + @Override + public Long _LocalPeer_getVendorId() { + return this.stack.getMetaData().getLocalPeer().getVendorId(); + } + + @Override + public Long _LocalPeer_getFirmware() { + return this.stack.getMetaData().getLocalPeer().getFirmware(); + } + + @Override + public String _LocalPeer_getURI() { + return this.stack.getMetaData().getLocalPeer().getUri().toString(); + } + + @Override + public String _LocalPeer_getRealmName() { + return this.stack.getMetaData().getLocalPeer().getRealmName(); + } + + @Override + public InetAddress[] _LocalPeer_getIPAddresses() { + return this.stack.getMetaData().getLocalPeer().getIPAddresses(); + } + + @Override + public Set _LocalPeer_getCommonApplicationIds() { + return this.stack.getMetaData().getLocalPeer().getCommonApplications(); + } + + @Override + public String[] _Network_Realms_getRealms() { + Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); + String[] realmNames = new String[realmEntries.length]; + + for (int i = 0; i < realmEntries.length; i++) { + realmNames[i] = realmEntries[i].getStringValue(RealmName.ordinal(), DEFAULT_STRING); + } + + return realmNames; + } + + @Override + public String[] _Network_Realms_getRealmPeers(String realmName) { + Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); + String[] realmHosts = new String[realmEntries.length]; + + for (Configuration realmEntry : realmEntries) { + if (realmEntry.getStringValue(RealmName.ordinal(), DEFAULT_STRING).equals(realmName)) { + + String realmHostsString = realmEntry.getStringValue(RealmHosts.ordinal(), DEFAULT_STRING); + if (!realmHostsString.equals(DEFAULT_STRING)) { + realmHosts = realmHostsString.replaceAll(" ", "").split(","); + } + } + } + + return realmHosts; + } + + @Override + public DiameterConfiguration getDiameterConfiguration() { + return new DiameterConfiguration(stack); + } + + @Override + public boolean _LocalPeer_isActive() { + return this.stack.isActive(); + } + + @Override + public boolean _Network_Peers_isPeerConnected(String name) { + try { + MutablePeerTable n = (MutablePeerTable) stack.unwrap(PeerTable.class); + PeerImpl p = ((PeerImpl) n.getPeer(name)); + return p != null ? p.getContext().isConnected() : false; + } + catch (Exception e) { + throw new RuntimeException("Failed to get connection availability for peer with name '" + "'.", e); + } + } + +} diff --git a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7MBean.java b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7MBean.java deleted file mode 100644 index 9a858c98d..000000000 --- a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerAS7MBean.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * TeleStax, Open Source Cloud Communications - * - * Copyright 2011-2015, Telestax Inc. and individual contributors - * by the @authors tag. - * - * This program is free software: you can redistribute it and/or modify - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation; either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - */ - -package org.mobicents.diameter.stack; - -import java.net.InetAddress; -import java.util.Set; - -import org.jdiameter.api.ApplicationId; -import org.jdiameter.api.Stack; -import org.mobicents.diameter.api.DiameterMessageFactory; -import org.mobicents.diameter.api.DiameterProvider; -import org.mobicents.diameter.stack.management.DiameterConfiguration; - -/** - * - * @author Alexandre Mendonca - */ - -public interface DiameterStackMultiplexerAS7MBean { - - String MBEAN_NAME_PREFIX = "diameter:Service=DiameterStackMultiplexer,Name="; - - void registerListener(DiameterListener listener, ApplicationId[] appIds) throws IllegalStateException; - - void unregisterListener(DiameterListener listener); - - //For sake of simplicity in the pre Gamma :) - Stack getStack(); - - DiameterProvider getProvider(); - - DiameterMessageFactory getMessageFactory(); - - DiameterStackMultiplexerAS7MBean getMultiplexerMBean(); - - // MANAGEMENT OPERATIONS - - // Get a Serializable Configuration - - DiameterConfiguration getDiameterConfiguration(); - - // Local Peer ---------------------------------------------------------- - - /** - * Changes the URI of the Local Peer. - * - * @param uri the new URI to be used by the Local Peer - */ - void _LocalPeer_setURI(String uri); - - /** - * Adds an IP Address to the Local Peer. - * @param ipAddress the IP Address to be added, if not present - */ - void _LocalPeer_addIPAddress(String ipAddress); - - /** - * Removes an IP Address from the Local Peer. - * - * @param ipAddress the IP Address to be removed, if present - */ - void _LocalPeer_removeIPAddress(String ipAddress); - - /** - * Changes the Realm of the Local Peer. - * - * @param realm the new Realm to be used by the Local Peer - */ - void _LocalPeer_setRealm(String realm); - - /** - * Sets the Local Peer Vendor-Id. - * - * @param vendorId the new Vendor-Id for the Peer - */ - void _LocalPeer_setVendorId(long vendorId); - - // Parameters ---------------------------------------------------------- - - /** - * Sets whether the stack will accept connections from unknown peers or not (default: true) - * - * @param acceptUndefinedPeer indicates if the stack will accept unknown connections - */ - void _Parameters_setAcceptUndefinedPeer(boolean acceptUndefinedPeer); - - /** - * Sets whether the stack will use URI (aaa://IP_ADDRESS:PORT) as FQDN. Some Peers require it. - * - * @param useUriAsFqdn indicates if the stack will use URI as FQDN - */ - void _Parameters_setUseUriAsFqdn(boolean useUriAsFqdn); - - /** - * Sets the value to consider a message as a duplicate, in ms. (default: 240000, 4 minutes). - * - * @param duplicateTimer the amount of time, in ms. - */ - void _Parameters_setDuplicateTimer(long duplicateTimer); - - // Parameters : Timeouts ----------------------------------------------- - - /** - * Sets the timeout for general Diameter messages, in ms. (default: 60000, 1 minute). - * - * @param messageTimeout the amount of time, in ms. - */ - void _Parameters_setMessageTimeout(long messageTimeout); - - /** - * Sets the timeout for stopping the stack. (default: 10000, 10 seconds). - * - * @param stopTimeout the amount of time, in ms. - */ - void _Parameters_setStopTimeout(long stopTimeout); - - /** - * Sets the timeout for CEA messages. (default: 10000, 10 seconds). - * - * @param ceaTimeout the amount of time, in ms. - */ - void _Parameters_setCeaTimeout(long ceaTimeout); - - /** - * Sets the timeout for inactiveness. (default: 20000, 20 seconds). - * - * @param iacTimeout the amount of time, in ms. - */ - void _Parameters_setIacTimeout(long iacTimeout); - - /** - * Sets the timeout for DWA messages. (default: 10000, 10 seconds). - * - * @param dwaTimeout the amount of time, in ms. - */ - void _Parameters_setDwaTimeout(long dwaTimeout); - - /** - * Sets the timeout for DPA messages. (default: 5000, 5 seconds). - * - * @param dpaTimeout the amount of time, in ms. - */ - void _Parameters_setDpaTimeout(long dpaTimeout); - - /** - * Sets the timeout for reconnecting. (default: 10000, 10 seconds). - * - * @param recTimeout the amount of time, in ms. - */ - void _Parameters_setRecTimeout(long recTimeout); - - void _Parameters_setConcurrentEntity(String name, String desc, Integer size); - - void _Parameters_setStatisticLoggerDelay(long delay); - - void _Parameters_setStatisticLoggerPause(long pause); - - // Network : Peers ----------------------------------------------------- - - /** - * Adds a peer definition to the stack. Same as element in XML Configuration. - * - * @param name the name/uri of the peer - * @param attemptConnect indicates if the stack should try to connect to this peer or wait for incoming connection - * @param rating the peer rating for decision on message routing - * @param realm name of the realm - */ - void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating, String realm); - - /** - * Removes a peer definition from stack. - * - * @param name the name/uri of the peer - */ - void _Network_Peers_removePeer(String name); - - // Network : Realms ---------------------------------------------------- - - /** - * Adds a new Realm to the stack. Same as element in XML Configuration. - * - * @param name the name of the Realm - * @param peers the Realm peer hosts, separated by comma - * @param appVendorId the vendor-id of the application supported by this realm - * @param appAcctId the accounting-id of the application supported by this realm - * @param appAuthId the authorization-id of the application supported by this realm - */ - void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId); - - void _Network_Realms_addRealm(String name, String peers, long appVendorId, long appAcctId, long appAuthId, String localAction, String agentConfiguration, - boolean isDynamic, int expTime); - - /** - * Removes a Realm from the stack. - * - * @param name the name of the Realm - */ - void _Network_Realms_removeRealm(String name); - - /** - * Adds a new Peer host to the Realm - * - * @param realmName the name of the Realm - * @param peerName the name/host of the Peer to be added - * @param attemptConnecting either try or not to connect the peer (client/server) - */ - void _Network_Realms_addPeerToRealm(String realmName, String peerName, boolean attemptConnecting); - - /** - * Removes a Peer host from the Realm - * - * @param realmName the name of the Realm - * @param peerName the name/host of the Peer to be removed - */ - void _Network_Realms_removePeerFromRealm(String realmName, String peerName); - - // Stack Operation ----------------------------------------------------- - - /** - * Operation to stop the stack. - * - */ - void stopStack(int disconnectCause); - - /** - * Operation to start the stack. - * - */ - void startStack(); - - // Validation ---------------------------------------------------------- - - /** - * Sets whether validation on Diameter messages/AVPs should be performed or not. - * - * @param enableValidation flag indicating if validation should be performed - */ - void _Validation_setEnabled(boolean enableValidation); - - // Configuration Dump -------------------------------------------------- - - /** - * Dumps full stack configuration. - * - * @return a String with stack configuration - */ - String dumpStackConfiguration(); - - // Information dump methods -------------------------------------------- - - String _LocalPeer_getProductName(); - - Long _LocalPeer_getVendorId(); - - Long _LocalPeer_getFirmware(); - - String _LocalPeer_getURI(); - - String _LocalPeer_getRealmName(); - - InetAddress[] _LocalPeer_getIPAddresses(); - - Set _LocalPeer_getCommonApplicationIds(); - - String[] _Network_Realms_getRealms(); - - String[] _Network_Realms_getRealmPeers(String realmName); - - boolean _LocalPeer_isActive(); - - boolean _Network_Peers_isPeerConnected(String name); - -} diff --git a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerMBean.java b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerMBean.java index 8b708584f..8599ac34f 100644 --- a/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerMBean.java +++ b/core/mux/jar/src/main/java/org/mobicents/diameter/stack/DiameterStackMultiplexerMBean.java @@ -43,14 +43,12 @@ package org.mobicents.diameter.stack; import java.net.InetAddress; -import java.util.List; import java.util.Set; import javax.management.MBeanException; import org.jboss.system.ServiceMBean; import org.jdiameter.api.ApplicationId; -import org.jdiameter.api.Peer; import org.jdiameter.api.Stack; import org.mobicents.diameter.api.DiameterMessageFactory; import org.mobicents.diameter.api.DiameterProvider; @@ -223,10 +221,9 @@ public interface DiameterStackMultiplexerMBean extends ServiceMBean { * @param name the name/uri of the peer * @param attemptConnect indicates if the stack should try to connect to this peer or wait for incoming connection * @param rating the peer rating for decision on message routing - * @param realm name of the realm * @throws MBeanException if the operation is unable to perform correctly */ - void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating, String realm) throws MBeanException; + void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating) throws MBeanException; /** * Removes a peer definition from stack. @@ -339,5 +336,5 @@ void _Network_Realms_addRealm(String name, String peers, long appVendorId, long boolean _LocalPeer_isActive() throws MBeanException; boolean _Network_Peers_isPeerConnected(String name) throws MBeanException; - List _Network_Peers_retrievePeer() throws MBeanException; + } diff --git a/core/mux/jar/src/main/module/module.xml b/core/mux/jar/src/main/module/module.xml deleted file mode 100644 index 6afe8e4aa..000000000 --- a/core/mux/jar/src/main/module/module.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/core/mux/jar/src/main/resources/META-INF/jboss-deployment-structure.xml b/core/mux/jar/src/main/resources/META-INF/jboss-deployment-structure.xml new file mode 100644 index 000000000..eddbf29e4 --- /dev/null +++ b/core/mux/jar/src/main/resources/META-INF/jboss-deployment-structure.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core/mux/pom.xml b/core/mux/pom.xml index 1d6f4d07f..242066793 100644 --- a/core/mux/pom.xml +++ b/core/mux/pom.xml @@ -15,10 +15,8 @@ - pom @@ -27,36 +25,6 @@ jar - - - - jboss5 - - false - - - sar-jboss-5 - - - - wildfly - - false - - - sar-wildfly - - - - @@ -92,15 +60,39 @@ false - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.17 - - true - - + + + maven-release + + sar-jboss-4 + sar-jboss-7 + sar-jboss-5 + + + + jboss4 + + sar-jboss-4 + + + + jboss5 + + true + + + sar-jboss-5 + + + + jboss7 + + sar-jboss-7 + + + + diff --git a/core/mux/sar-jboss-4/pom.xml b/core/mux/sar-jboss-4/pom.xml new file mode 100644 index 000000000..7b6ab17bd --- /dev/null +++ b/core/mux/sar-jboss-4/pom.xml @@ -0,0 +1,169 @@ + + + 4.0.0 + + + org.mobicents.diameter + restcomm-diameter-mux-parent + 1.7.0-SNAPSHOT + ../pom.xml + + + restcomm-diameter-mux-sar-jboss-4 + + Restcomm :: Diameter Multiplexer :: ${project.artifactId} + + jboss-sar + + + + ${project.groupId} + restcomm-diameter-mux-jar + ${project.version} + runtime + + + + + restcomm-diameter-mux-${project.version} + + + + maven-resources-plugin + 2.7 + + + copy-resources + validate + + copy-resources + + + true + ${basedir}/target/classes/config + + + ../common/config + false + + + + + + + + + + org.codehaus.mojo + jboss-packaging-maven-plugin + 2.2 + true + + + apache-xerces:xml-apis + org.jboss.logging:jboss-logging-spi + org.jboss:jboss-common-core + org.jboss:jboss-vfs + org.jboss:jbossxb + org.jboss:jboss-reflect + wutka-dtdparser:dtdparser121 + javax.activation:activation + sun-jaxb:jaxb-api + org.jboss.deployers:jboss-deployers-core-spi + org.jboss.deployers:jboss-deployers-impl + org.jboss.deployers:jboss-deployers-spi + org.jboss.deployers:jboss-deployers-structure-spi + org.jboss.deployers:jboss-deployers-client-spi + org.jboss.man:jboss-managed + org.jboss.man:jboss-metatype + org.jboss:jboss-mdr + org.jboss.integration:jboss-classloading-spi + org.jboss.cl:jboss-classloading + org.jboss.cl:jboss-classloader + org.jboss.microcontainer:jboss-kernel + org.jboss.microcontainer:jboss-dependency + javassist:javassist + org.jboss.deployers:jboss-deployers-vfs + org.jboss.deployers:jboss-deployers-vfs-spi + stax:stax-api + org.jboss.cl:jboss-classloading-vfs + org.jboss.deployers:jboss-deployers-core + org.jboss.deployers:jboss-deployers-client + org.jboss.jbossas:jboss-as-j2se + oswego-concurrent:concurrent + org.jboss.bootstrap:jboss-bootstrap + org.jboss.jbossas:jboss-as-system + org.jboss.jbossas:jboss-as-system-jmx + org.jboss.aop:jboss-aop + org.apache.ant:ant + org.apache.ant:ant-launcher + qdox:qdox + trove:trove + log4j:log4j + org.jboss.logging:jboss-logging-log4j + org.jboss.integration:jboss-profileservice-spi + org.jboss.microcontainer:jboss-aop-mc-int + org.jboss.jbossas:jboss-as-jmx + org.jboss.jbossas:jboss-as-j2se + org.jboss.jbossas:jboss-as-mbeans + dom4j:dom4j + bcel:bcel + org.jboss.test:jboss-test + org.apache.ant:ant-junit + junit:junit + jboss.profiler.jvmti:jboss-profiler-jvmti + org.jboss.jbossas:jboss-server-manager + org.jboss.naming:jnp-client + org.jboss.security:jbosssx-client + org.jboss.security:jboss-security-spi + + xml-apis:xml-apis + + + + + + + + maven-antrun-plugin + + + deploy + install + + run + + + + + + + + + + + + + + + + undeploy + clean + + run + + + + + + + + + + + + + diff --git a/core/mux/sar-jboss-4/src/main/resources/META-INF/jboss-service.xml b/core/mux/sar-jboss-4/src/main/resources/META-INF/jboss-service.xml new file mode 100644 index 000000000..a7e7accf1 --- /dev/null +++ b/core/mux/sar-jboss-4/src/main/resources/META-INF/jboss-service.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/core/mux/sar-jboss-5/pom.xml b/core/mux/sar-jboss-5/pom.xml index d08d7ed0e..98f159b29 100644 --- a/core/mux/sar-jboss-5/pom.xml +++ b/core/mux/sar-jboss-5/pom.xml @@ -22,22 +22,6 @@ ${project.version} runtime - - - org.restcomm.cluster - core - compile - - - org.restcomm.cluster - cache - compile - - - org.restcomm.cluster - timers - compile - @@ -60,7 +44,7 @@ ../common/config - jdiameter-infinispan.xml + false @@ -132,21 +116,12 @@ org.jboss.naming:jnp-client org.jboss.security:jbosssx-client org.jboss.security:jboss-security-spi - + picocontainer:picocontainer xml-apis:xml-apis - - + @@ -170,9 +145,6 @@ - - diff --git a/core/mux/sar-wildfly/pom.xml b/core/mux/sar-jboss-7/pom.xml similarity index 53% rename from core/mux/sar-wildfly/pom.xml rename to core/mux/sar-jboss-7/pom.xml index e86c30064..3a1c2a541 100644 --- a/core/mux/sar-wildfly/pom.xml +++ b/core/mux/sar-jboss-7/pom.xml @@ -9,48 +9,18 @@ ../pom.xml - restcomm-diameter-mux-sar-wildfly + restcomm-diameter-mux-sar-jboss-7 Restcomm :: Diameter Multiplexer :: ${project.artifactId} jboss-sar - - 2.2.0.Final - - org.restcomm.diameter.extension - org/restcomm/diameter/extension - - - - - - org.wildfly.core - wildfly-controller - ${version.wildfly.core} - provided - - - org.wildfly.core - wildfly-jmx - ${version.wildfly.core} - provided - - - org.wildfly.core - wildfly-server - ${version.wildfly.core} - provided - - - - ${project.groupId} restcomm-diameter-mux-jar ${project.version} - + runtime @@ -63,22 +33,6 @@ slf4j-log4j12 ${slf4j.version} - - - org.wildfly.core - wildfly-controller - provided - - - org.wildfly.core - wildfly-jmx - provided - - - org.wildfly.core - wildfly-server - provided - @@ -124,7 +78,6 @@ org.jboss.jbossas:jboss-as-j2se oswego-concurrent:concurrent org.jboss.bootstrap:jboss-bootstrap - org.jboss.jbossas:jboss-as-system org.jboss.jbossas:jboss-as-system-jmx org.jboss.aop:jboss-aop @@ -149,19 +102,12 @@ org.jboss.naming:jnp-client org.jboss.security:jbosssx-client org.jboss.security:jboss-security-spi - - - + picocontainer:picocontainer xml-apis:xml-apis - - + @@ -182,12 +128,9 @@ - - - + - + @@ -196,78 +139,30 @@ - + - - - - + + + + - + - - - - - - - - - - - - - - - - - + - - - - - - - - + + + + - - - - - - - - - - - - - + + - - - - - - - @@ -279,9 +174,7 @@ - - - + diff --git a/core/mux/sar-jboss-7/src/main/resources/META-INF/jboss-deployment-structure.xml b/core/mux/sar-jboss-7/src/main/resources/META-INF/jboss-deployment-structure.xml new file mode 100644 index 000000000..d24511440 --- /dev/null +++ b/core/mux/sar-jboss-7/src/main/resources/META-INF/jboss-deployment-structure.xml @@ -0,0 +1,10 @@ + +   true + +    +      +        +      +    + + \ No newline at end of file diff --git a/core/mux/sar-wildfly/src/main/resources/META-INF/jboss-service.xml b/core/mux/sar-jboss-7/src/main/resources/META-INF/jboss-service.xml similarity index 100% rename from core/mux/sar-wildfly/src/main/resources/META-INF/jboss-service.xml rename to core/mux/sar-jboss-7/src/main/resources/META-INF/jboss-service.xml diff --git a/core/mux/sar-wildfly/src/main/resources/META-INF/module.xml b/core/mux/sar-jboss-7/src/main/resources/META-INF/module.xml similarity index 97% rename from core/mux/sar-wildfly/src/main/resources/META-INF/module.xml rename to core/mux/sar-jboss-7/src/main/resources/META-INF/module.xml index 811e29a34..d18a5047a 100644 --- a/core/mux/sar-wildfly/src/main/resources/META-INF/module.xml +++ b/core/mux/sar-jboss-7/src/main/resources/META-INF/module.xml @@ -20,7 +20,7 @@ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. --> - + diff --git a/core/mux/sar-wildfly/src/main/assemble/descriptor.xml b/core/mux/sar-wildfly/src/main/assemble/descriptor.xml deleted file mode 100755 index 15896ebcc..000000000 --- a/core/mux/sar-wildfly/src/main/assemble/descriptor.xml +++ /dev/null @@ -1,22 +0,0 @@ - - diameter-mux-bean - - dir - - main - - - - src/main/module - / - true - - - - - - / - true - - - diff --git a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/DiameterMuxExtension.java b/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/DiameterMuxExtension.java deleted file mode 100644 index 3fc278913..000000000 --- a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/DiameterMuxExtension.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.mobicents.diameter.extension; - -import org.jboss.as.controller.*; -import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; -import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; -import org.jboss.as.controller.parsing.ExtensionParsingContext; -import org.jboss.as.controller.parsing.ParseUtils; -import org.jboss.as.controller.persistence.SubsystemMarshallingContext; -import org.jboss.as.controller.registry.ManagementResourceRegistration; -import org.jboss.as.controller.registry.OperationEntry; -import org.jboss.dmr.ModelNode; -import org.jboss.staxmapper.XMLElementReader; -import org.jboss.staxmapper.XMLElementWriter; -import org.jboss.staxmapper.XMLExtendedStreamReader; -import org.jboss.staxmapper.XMLExtendedStreamWriter; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import java.util.List; - -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIBE; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; - - -/** - * @author Kabir Khan - */ -public class DiameterMuxExtension implements Extension { - - /** - * The name space used for the {@code substystem} element - */ - public static final String NAMESPACE = "urn:org.restcomm:diameter-mux:1.0"; - - /** - * The name of our subsystem within the model. - */ - public static final String SUBSYSTEM_NAME = "restcomm-diameter-mux"; - - /** - * The parser used for parsing our subsystem - */ - private final SubsystemParser parser = new SubsystemParser(); - - protected static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); - private static final String RESOURCE_NAME = DiameterMuxExtension.class.getPackage().getName() + ".LocalDescriptions"; - - static StandardResourceDescriptionResolver getResourceDescriptionResolver(final String keyPrefix) { - String prefix = SUBSYSTEM_NAME + (keyPrefix == null ? "" : "." + keyPrefix); - return new StandardResourceDescriptionResolver(prefix, RESOURCE_NAME, DiameterMuxExtension.class.getClassLoader(), true, false); - } - - @Override - public void initializeParsers(ExtensionParsingContext context) { - context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE, parser); - } - - - @Override - public void initialize(ExtensionContext context) { - final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, 1, 0); - final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(SubsystemDefinition.INSTANCE); - - final OperationDefinition describeOp = new SimpleOperationDefinitionBuilder(DESCRIBE, - getResourceDescriptionResolver(null)) - .setEntryType(OperationEntry.EntryType.PRIVATE) - .build(); - registration.registerOperationHandler(describeOp, GenericSubsystemDescribeHandler.INSTANCE, false); - - subsystem.registerXMLElementWriter(parser); - } - - private static ModelNode createAddSubsystemOperation() { - final ModelNode subsystem = new ModelNode(); - subsystem.get(OP).set(ADD); - subsystem.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME); - return subsystem; - } - - /** - * The subsystem parser, which uses stax to read and write to and from xml - */ - private static class SubsystemParser implements XMLStreamConstants, XMLElementReader>, XMLElementWriter { - - /** - * {@inheritDoc} - */ - @Override - public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException { - context.startSubsystemElement(DiameterMuxExtension.NAMESPACE, false); - writer.writeEndElement(); - } - - /** - * {@inheritDoc} - */ - @Override - public void readElement(XMLExtendedStreamReader reader, List list) throws XMLStreamException { - // Require no content - ParseUtils.requireNoContent(reader); - list.add(createAddSubsystemOperation()); - } - } - -} diff --git a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/DiameterMuxService.java b/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/DiameterMuxService.java deleted file mode 100644 index 51488d2ae..000000000 --- a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/DiameterMuxService.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.mobicents.diameter.extension; - -//import org.jboss.logging.Logger; -import org.jboss.msc.service.*; -import org.jboss.msc.value.InjectedValue; -import org.mobicents.diameter.stack.DiameterStackMultiplexerAS7; - -import javax.management.MBeanServer; -import javax.management.ObjectName; - -public class DiameterMuxService implements Service { - - //private final Logger log = Logger.getLogger(DiameterMuxService.class); - - public static ServiceName getServiceName() { - return ServiceName.of("restcomm","diameter-mux"); - } - - private final InjectedValue mbeanServer = new InjectedValue(); - public InjectedValue getMbeanServer() { - return mbeanServer; - } - - private DiameterStackMultiplexerAS7 diameterMuxBean; - - @Override - public DiameterMuxService getValue() throws IllegalStateException, IllegalArgumentException { - return this; - } - - @Override - public void start(StartContext context) throws StartException { - //log.info("Starting DiameterMuxService"); - - diameterMuxBean = new DiameterStackMultiplexerAS7(); - //try { - //StandardMBean standardMBean = - // new StandardMBean(diameterMuxBean, DiameterStackMultiplexerAS7MBean.class); - registerMBean(diameterMuxBean, DiameterStackMultiplexerAS7.OBJECT_NAME); - //} catch (NotCompliantMBeanException e) { - // e.printStackTrace(); - //} finally { - diameterMuxBean.startService(); - //} - } - - @Override - public void stop(StopContext context) { - //log.info("Stopping DiameterMuxService"); - - diameterMuxBean.stopService(); - unregisterMBean(DiameterStackMultiplexerAS7.OBJECT_NAME); - } - - private void registerMBean(Object mBean, String name) throws StartException { - try { - getMbeanServer().getValue().registerMBean(mBean, new ObjectName(name)); - } catch (Throwable e) { - throw new StartException(e); - } - } - - private void unregisterMBean(String name) { - try { - getMbeanServer().getValue().unregisterMBean(new ObjectName(name)); - } catch (Throwable e) { - //log.error("failed to unregister mbean", e); - } - } -} diff --git a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemAdd.java b/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemAdd.java deleted file mode 100644 index 1147341b6..000000000 --- a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemAdd.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.mobicents.diameter.extension; - -import java.util.List; - -import org.jboss.as.controller.AbstractBoottimeAddStepHandler; -import org.jboss.as.controller.OperationContext; -import org.jboss.as.controller.OperationFailedException; -import org.jboss.as.controller.ServiceVerificationHandler; -import org.jboss.as.jmx.MBeanServerService; -import org.jboss.dmr.ModelNode; -//import org.jboss.logging.Logger; -import org.jboss.msc.service.ServiceController; - -import org.jboss.msc.service.ServiceName; - -import javax.management.MBeanServer; - -/** - * Handler responsible for adding the subsystem resource to the model - * - * @author Kabir Khan - */ -class SubsystemAdd extends AbstractBoottimeAddStepHandler { - - static final SubsystemAdd INSTANCE = new SubsystemAdd(); - - //private final Logger log = Logger.getLogger(SubsystemAdd.class); - - private SubsystemAdd() { - } - - /** {@inheritDoc} */ - @Override - protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { - //log.info("Populating the model"); - model.setEmptyObject(); - } - - /** {@inheritDoc} */ - @Override - public void performBoottime(OperationContext context, ModelNode operation, ModelNode model, - ServiceVerificationHandler verificationHandler, List> newControllers) - throws OperationFailedException { - - // Install service with MBean SleeConnectionTest - - DiameterMuxService service = new DiameterMuxService(); - ServiceName name = DiameterMuxService.getServiceName(); - ServiceController controller = context.getServiceTarget() - .addService(name, service) - .addDependency(MBeanServerService.SERVICE_NAME, MBeanServer.class, service.getMbeanServer()) - .addListener(verificationHandler) - .setInitialMode(ServiceController.Mode.ACTIVE) - .install(); - newControllers.add(controller); - - } -} diff --git a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemDefinition.java b/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemDefinition.java deleted file mode 100644 index fbb2ec813..000000000 --- a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemDefinition.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.mobicents.diameter.extension; - -import org.jboss.as.controller.SimpleResourceDefinition; -import org.jboss.as.controller.registry.ManagementResourceRegistration; - -/** - * @author Tomaz Cerar - */ -public class SubsystemDefinition extends SimpleResourceDefinition { - public static final SubsystemDefinition INSTANCE = new SubsystemDefinition(); - - private SubsystemDefinition() { - super(DiameterMuxExtension.SUBSYSTEM_PATH, - DiameterMuxExtension.getResourceDescriptionResolver(null), - //We always need to add an 'add' operation - SubsystemAdd.INSTANCE, - //Every resource that is added, normally needs a remove operation - SubsystemRemove.INSTANCE); - } - - @Override - public void registerOperations(ManagementResourceRegistration resourceRegistration) { - super.registerOperations(resourceRegistration); - //you can register aditional operations here - } - - @Override - public void registerAttributes(ManagementResourceRegistration resourceRegistration) { - //you can register attributes here - } -} diff --git a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemRemove.java b/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemRemove.java deleted file mode 100644 index 409bcccb4..000000000 --- a/core/mux/sar-wildfly/src/main/java/org/mobicents/diameter/extension/SubsystemRemove.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.mobicents.diameter.extension; - -import org.jboss.as.controller.AbstractRemoveStepHandler; -import org.jboss.as.controller.OperationContext; -import org.jboss.as.controller.OperationFailedException; -import org.jboss.dmr.ModelNode; -//import org.jboss.logging.Logger; -import org.jboss.msc.service.ServiceName; - -/** - * Handler responsible for removing the subsystem resource from the model - * - * @author Kabir Khan - */ -class SubsystemRemove extends AbstractRemoveStepHandler { - - static final SubsystemRemove INSTANCE = new SubsystemRemove(); - - //private final Logger log = Logger.getLogger(SubsystemRemove.class); - - private SubsystemRemove() { - } - - @Override - protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { - //Remove any services installed by the corresponding add handler here - ServiceName name = DiameterMuxService.getServiceName(); - context.removeService(name); - } - - -} diff --git a/core/mux/sar-wildfly/src/main/module/module.xml b/core/mux/sar-wildfly/src/main/module/module.xml deleted file mode 100644 index b440c3839..000000000 --- a/core/mux/sar-wildfly/src/main/module/module.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/mux/sar-wildfly/src/main/resources/META-INF/services/org.jboss.as.controller.Extension b/core/mux/sar-wildfly/src/main/resources/META-INF/services/org.jboss.as.controller.Extension deleted file mode 100644 index 1a026c432..000000000 --- a/core/mux/sar-wildfly/src/main/resources/META-INF/services/org.jboss.as.controller.Extension +++ /dev/null @@ -1 +0,0 @@ -org.mobicents.diameter.extension.DiameterMuxExtension diff --git a/core/mux/sar-wildfly/src/main/resources/org/mobicents/diameter/extension/LocalDescriptions.properties b/core/mux/sar-wildfly/src/main/resources/org/mobicents/diameter/extension/LocalDescriptions.properties deleted file mode 100644 index 25ccd0a78..000000000 --- a/core/mux/sar-wildfly/src/main/resources/org/mobicents/diameter/extension/LocalDescriptions.properties +++ /dev/null @@ -1,3 +0,0 @@ -restcomm-diameter-mux=Restcomm Diameter MUX Subsystem -restcomm-diameter-mux.add=Operation adds Restcomm Diameter MUX Subsystem -restcomm-diameter-mux.remove=Operation removes Restcomm Diameter MUX Subsystem \ No newline at end of file diff --git a/core/mux/sar-wildfly/src/main/resources/schema/restcomm-diameter-mux.xsd b/core/mux/sar-wildfly/src/main/resources/schema/restcomm-diameter-mux.xsd deleted file mode 100644 index 53e9ad15d..000000000 --- a/core/mux/sar-wildfly/src/main/resources/schema/restcomm-diameter-mux.xsd +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/core/pom.xml b/core/pom.xml index 933a44e2e..985991033 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -22,7 +22,7 @@ - 1.7.2 + 1.5.8 2.13.5 1.5.5 diff --git a/examples/charging-server-simulator/src/main/assembly/standalone.xml b/examples/charging-server-simulator/src/main/assembly/standalone.xml index ebc7f020f..f39df301e 100644 --- a/examples/charging-server-simulator/src/main/assembly/standalone.xml +++ b/examples/charging-server-simulator/src/main/assembly/standalone.xml @@ -10,7 +10,7 @@ true - org.mobicents.diameter:restcomm-diameter-mux-jar + org.mobicents.diameter:mobicents-diameter-mux-jar org.mobicents.diameter:jdiameter-api org.mobicents.diameter:jdiameter-impl org.slf4j:slf4j-api diff --git a/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java b/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java index 19826ecb3..aaa30633f 100644 --- a/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java +++ b/examples/charging-server-simulator/src/main/java/org/mobicents/servers/diameter/charging/ChargingServerSimulator.java @@ -19,7 +19,6 @@ import org.jdiameter.api.NetworkReqListener; import org.jdiameter.api.Peer; import org.jdiameter.api.Request; -import org.jdiameter.api.ResultCode; import org.jdiameter.api.app.AppAnswerEvent; import org.jdiameter.api.app.AppRequestEvent; import org.jdiameter.api.app.AppSession; @@ -198,9 +197,9 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque } JCreditControlAnswer cca = null; try { - long requestedUnits = ccrAvps.getAvp(Avp.REQUESTED_SERVICE_UNIT).getGrouped().getAvp(Avp.CC_TIME).getInteger32(); - String subscriptionId = ccrAvps.getAvp(Avp.SUBSCRIPTION_ID).getGrouped().getAvp(Avp.SUBSCRIPTION_ID_DATA).getUTF8String(); - String serviceContextId = ccrAvps.getAvp(Avp.SERVICE_CONTEXT_ID).getUTF8String(); + long requestedUnits = ccrAvps.getAvp(437).getGrouped().getAvp(420).getInteger32(); + String subscriptionId = ccrAvps.getAvp(443).getGrouped().getAvp(444).getUTF8String(); + String serviceContextId = ccrAvps.getAvp(461).getUTF8String(); if (logger.isInfoEnabled()) { logger.info(">> '" + subscriptionId + "' requested " + requestedUnits + " units for '" + serviceContextId + "'."); @@ -220,12 +219,12 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque } else { // Check if not first request, should have Used-Service-Unit AVP - if (ccrAvps.getAvp(Avp.CC_REQUEST_NUMBER) != null && ccrAvps.getAvp(Avp.CC_REQUEST_NUMBER).getUnsigned32() >= 1) { - Avp usedServiceUnit = ccrAvps.getAvp(Avp.USED_SERVICE_UNIT); + if (ccrAvps.getAvp(415) != null && ccrAvps.getAvp(415).getUnsigned32() >= 1) { + Avp usedServiceUnit = ccrAvps.getAvp(446); if (usedServiceUnit != null) { Long wereReserved = reserved.remove(subscriptionId + "_" + serviceContextId); wereReserved = wereReserved == null ? 0 : wereReserved; - long wereUsed = usedServiceUnit.getGrouped().getAvp(Avp.CC_TIME).getUnsigned32(); + long wereUsed = usedServiceUnit.getGrouped().getAvp(420).getUnsigned32(); long remaining = wereReserved - wereUsed; if (logger.isInfoEnabled()) { @@ -237,7 +236,7 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque } long grantedUnits = Math.min(requestedUnits, balance); - cca = createCCA(session, request, grantedUnits, ResultCode.SUCCESS); + cca = createCCA(session, request, grantedUnits, 2001); reserved.put(subscriptionId + "_" + serviceContextId, grantedUnits); balance -= grantedUnits; @@ -301,7 +300,7 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque // *[ Restriction-Filter-Rule ] // *[ Filter-Id ] // [ Redirect-Server ] - AvpSet finalUnitIndicationAvp = cca.getMessage().getAvps().addGroupedAvp(Avp.FINAL_UNIT_INDICATION); + AvpSet finalUnitIndicationAvp = cca.getMessage().getAvps().addGroupedAvp(430); // 8.35. Final-Unit-Action AVP // @@ -329,7 +328,7 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque // according to the IP packet filters identified by the Filter-Id // AVP. All the packets not matching the filters MUST be dropped // (see section 5.6.3). - finalUnitIndicationAvp.addAvp(Avp.FINAL_UNIT_ACTION, 0); + finalUnitIndicationAvp.addAvp(449, 0); } } } @@ -343,7 +342,7 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque } } - //cca.getMessage().getAvps().addAvp(Avp.SERVICE_CONTEXT_ID, serviceContextId, false); + //cca.getMessage().getAvps().addAvp(461, serviceContextId, false); session.sendCreditControlAnswer(cca); } catch (Exception e) { @@ -356,8 +355,8 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque logger.info("<< Received Credit-Control-Request [TERMINATION]"); } try { - String subscriptionId = ccrAvps.getAvp(Avp.SUBSCRIPTION_ID).getGrouped().getAvp(Avp.SUBSCRIPTION_ID_DATA).getUTF8String(); - String serviceContextId = ccrAvps.getAvp(Avp.SERVICE_CONTEXT_ID).getUTF8String(); + String subscriptionId = ccrAvps.getAvp(443).getGrouped().getAvp(444).getUTF8String(); + String serviceContextId = ccrAvps.getAvp(461).getUTF8String(); if (logger.isInfoEnabled()) { logger.info(">> '" + subscriptionId + "' requested service termination for '" + serviceContextId + "'."); @@ -365,11 +364,11 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque Long balance = accounts.get(subscriptionId); - if (ccrAvps.getAvp(Avp.CC_REQUEST_NUMBER) != null && ccrAvps.getAvp(Avp.CC_REQUEST_NUMBER).getUnsigned32() >= 1) { - Avp usedServiceUnit = ccrAvps.getAvp(Avp.USED_SERVICE_UNIT); + if (ccrAvps.getAvp(415) != null && ccrAvps.getAvp(415).getUnsigned32() >= 1) { + Avp usedServiceUnit = ccrAvps.getAvp(446); if (usedServiceUnit != null) { long wereReserved = reserved.remove(subscriptionId + "_" + serviceContextId); - long wereUsed = usedServiceUnit.getGrouped().getAvp(Avp.CC_TIME).getUnsigned32(); + long wereUsed = usedServiceUnit.getGrouped().getAvp(420).getUnsigned32(); long remaining = wereReserved - wereUsed; if (logger.isInfoEnabled()) { @@ -385,7 +384,7 @@ public void doCreditControlRequest(ServerCCASession session, JCreditControlReque } accounts.put(subscriptionId, balance); - cca = createCCA(session, request, -1, ResultCode.SUCCESS); + cca = createCCA(session, request, -1, 2001); // 8.7. Cost-Information AVP // // The Cost-Information AVP (AVP Code 423) is of type Grouped, and it is @@ -490,11 +489,11 @@ private JCreditControlAnswer createCCA(ServerCCASession session, JCreditControlR // { CC-Request-Type } // Using the same as the one present in request - ccaAvps.addAvp(ccrAvps.getAvp(Avp.CC_REQUEST_TYPE)); + ccaAvps.addAvp(ccrAvps.getAvp(416)); // { CC-Request-Number } // Using the same as the one present in request - ccaAvps.addAvp(ccrAvps.getAvp(Avp.CC_REQUEST_NUMBER)); + ccaAvps.addAvp(ccrAvps.getAvp(415)); // [ User-Name ] // [ CC-Session-Failover ] @@ -529,10 +528,10 @@ private JCreditControlAnswer createCCA(ServerCCASession session, JCreditControlR // [ CC-Service-Specific-Units ] // *[ AVP ] if (grantedUnits >= 0) { - AvpSet gsuAvp = ccaAvps.addGroupedAvp(Avp.GRANTED_SERVICE_UNIT); + AvpSet gsuAvp = ccaAvps.addGroupedAvp(431); // Fetch AVP/Value from Request - // gsuAvp.addAvp(ccrAvps.getAvp(Avp.REQUESTED_SERVICE_UNIT).getGrouped().getAvp(Avp.CC_TIME)); - gsuAvp.addAvp(Avp.CC_TIME, grantedUnits, true); + // gsuAvp.addAvp(ccrAvps.getAvp(437).getGrouped().getAvp(420)); + gsuAvp.addAvp(420, grantedUnits, true); } // *[ Multiple-Services-Credit-Control ] diff --git a/examples/charging-server-simulator/src/main/resources/dictionary.xml b/examples/charging-server-simulator/src/main/resources/dictionary.xml index 6f7c02bc2..91bf1acf5 100644 --- a/examples/charging-server-simulator/src/main/resources/dictionary.xml +++ b/examples/charging-server-simulator/src/main/resources/dictionary.xml @@ -38,7 +38,6 @@ - @@ -2104,7 +2103,6 @@ - @@ -2980,7 +2978,7 @@ - + @@ -3245,13 +3243,6 @@ - - - - - - - @@ -3338,243 +3329,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/guide1/src/main/resources/org/example/client/dictionary.xml b/examples/guide1/src/main/resources/org/example/client/dictionary.xml index 6f7c02bc2..91bf1acf5 100644 --- a/examples/guide1/src/main/resources/org/example/client/dictionary.xml +++ b/examples/guide1/src/main/resources/org/example/client/dictionary.xml @@ -38,7 +38,6 @@ - @@ -2104,7 +2103,6 @@ - @@ -2980,7 +2978,7 @@ - + @@ -3245,13 +3243,6 @@ - - - - - - - @@ -3338,243 +3329,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/guide1/src/main/resources/org/example/server/dictionary.xml b/examples/guide1/src/main/resources/org/example/server/dictionary.xml index 6f7c02bc2..91bf1acf5 100644 --- a/examples/guide1/src/main/resources/org/example/server/dictionary.xml +++ b/examples/guide1/src/main/resources/org/example/server/dictionary.xml @@ -38,7 +38,6 @@ - @@ -2104,7 +2103,6 @@ - @@ -2980,7 +2978,7 @@ - + @@ -3245,13 +3243,6 @@ - - - - - - - @@ -3338,243 +3329,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 5408bf17d..70144a803 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.mobicents restcomm-parent - 2.27.47 + 2.27.32 org.mobicents.diameter @@ -32,8 +32,6 @@ true 6.18 1.7 - - @@ -75,35 +73,6 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - restcomm-releases-repository - https://oss.sonatype.org/ - - - - deploy-to-sonatype - deploy - - deploy - - release - - - - - org.apache.maven.plugins @@ -234,26 +203,6 @@ - - - jboss5 - - true - - - 1.15.29 - - - - wildfly - - false - - - 3.0.0.13 - - - testsuite @@ -292,29 +241,6 @@ - - - - org.restcomm.cluster - core - ${cluster.version} - - - - org.restcomm.cluster - cache - ${cluster.version} - - - - org.restcomm.cluster - timers - ${cluster.version} - - - - - mobicents-public-repository-group diff --git a/release/build.xml b/release/build.xml index 2f493ca69..2cd1e0a3c 100644 --- a/release/build.xml +++ b/release/build.xml @@ -38,8 +38,8 @@ - + @@ -51,6 +51,7 @@ + @@ -58,16 +59,17 @@ + + + + + - - - - @@ -77,8 +79,8 @@ - - + + @@ -91,38 +93,27 @@ - + - - - - - - - - - - Checkout Diameter Core (jDiameter @tag:${CORE_JDIAMETER_TAG}) - + Checkout Diameter SLEE Diameter Package v${SLEE_DIAMETER_PACKAGE_VERSION} - + @@ -132,7 +123,7 @@ Checkout Diameter Example @{example.name} v${EXAMPLE_JAINSLEE_@{example.name}_VERSION} - + @@ -141,7 +132,7 @@ Checkout Diameter RHQ Plugin - + @@ -150,23 +141,17 @@ - - - - - - - + - - + + Building JAIN SLEE Diameter Package v${SLEE_DIAMETER_PACKAGE_VERSION} - - + + @@ -174,7 +159,7 @@ Build Diameter @{example.name} Example - + @@ -187,11 +172,11 @@ - + Build Diameter RHQ Plugin Documentation - + @@ -199,7 +184,7 @@ - + @@ -230,15 +215,13 @@ - - + + - - + @@ -435,16 +418,16 @@ - - + + - + - - + + @@ -457,7 +440,7 @@ - + @@ -484,15 +467,13 @@ - + - + - - - + - - - - - diff --git a/release/release-build-wildfly.xml b/release/release-build-wildfly.xml deleted file mode 100644 index 836d3b9a7..000000000 --- a/release/release-build-wildfly.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]]> - - ]]> - - - - ]]> - - ]]> - - - - - - - ]]> - - - - - - - - ]]> - - - - - - - - - - ]]> - - - - - ]]> - - - - - - - - - - - - - diff --git a/release/xmltask.jar b/release/xmltask.jar deleted file mode 100644 index 8c5510dcb..000000000 Binary files a/release/xmltask.jar and /dev/null differ diff --git a/testsuite/load/core/src/main/resources/dictionary.xml b/testsuite/load/core/src/main/resources/dictionary.xml index 6f7c02bc2..91bf1acf5 100644 --- a/testsuite/load/core/src/main/resources/dictionary.xml +++ b/testsuite/load/core/src/main/resources/dictionary.xml @@ -38,7 +38,6 @@ - @@ -2104,7 +2103,6 @@ - @@ -2980,7 +2978,7 @@ - + @@ -3245,13 +3243,6 @@ - - - - - - - @@ -3338,243 +3329,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/pom.xml b/testsuite/pom.xml index c4cc09f7f..602ed2b3a 100644 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -19,8 +19,15 @@ 1.0.9 2.13.5 - 1.7.2 + 1.5.8 4.11 + 2.2.0.M2 + 2.1.8.GA + 2.1.8.GA + 2.1.8.GA + 2.1.8.GA + 2.0.1-BETA + 5.0.4.GA 2.19 @@ -78,6 +85,59 @@ slf4j-log4j12 ${slf4j.version} + + org.jboss.microcontainer + jboss-kernel + ${version.jboss.microcontainer} + + + + org.jboss.microcontainer + jboss-dependency + ${version.jboss.microcontainer} + + + + org.jboss.microcontainer + jboss-aop-mc-int + ${version.jboss.microcontainer} + + + + org.jboss.aop + jboss-aop + ${version.jboss.aop} + + + + org.jboss.aop + jboss-aop-asintegration-mc + ${version.aop.asintegration.mc} + + + + org.jboss.aop + jboss-aop-asintegration-core + ${version.aop.asintegration.core} + + + + org.jboss.aop + jboss-aop-asintegration-jmx + ${version.aop.asintegration.jmx} + + + + jboss + jbosssx-client + ${version.jboss.sx.client} + + + + org.jboss.naming + jnp-client + ${version.jboss.naming.jnp-client} + diff --git a/testsuite/test-framework/src/test/resources/dictionary.xml b/testsuite/test-framework/src/test/resources/dictionary.xml index 6f7c02bc2..91bf1acf5 100644 --- a/testsuite/test-framework/src/test/resources/dictionary.xml +++ b/testsuite/test-framework/src/test/resources/dictionary.xml @@ -38,7 +38,6 @@ - @@ -2104,7 +2103,6 @@ - @@ -2980,7 +2978,7 @@ - + @@ -3245,13 +3243,6 @@ - - - - - - - @@ -3338,243 +3329,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractDeferredClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractDeferredClient.java new file mode 100644 index 000000000..850ed9cd4 --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractDeferredClient.java @@ -0,0 +1,530 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg; + +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpSet; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.Mode; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ClientSLgSessionListener; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.slg.LocationReportRequestImpl; +import org.jdiameter.common.impl.app.slg.SLgSessionFactoryImpl; +import org.mobicents.diameter.stack.functional.TBase; + +/** + * + * @author Fernando Mendioroz + * + */ +public abstract class AbstractDeferredClient extends TBase implements ClientSLgSessionListener { + + // NOTE: implementing NetworkReqListener since its required for stack to + // know we support it... ech. + + protected ClientSLgSession clientSLgSession; + + public void init(InputStream configStream, String clientID) throws Exception { + try { + super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777255)); + SLgSessionFactoryImpl sLgSessionFactory = new SLgSessionFactoryImpl(this.sessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLgSession.class, sLgSessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLgSession.class, sLgSessionFactory); + + sLgSessionFactory .setClientSessionListener(this); + + this.clientSLgSession = ((ISessionFactory) this.sessionFactory).getNewAppSession(this.sessionFactory.getSessionId("xx-SLg-TESTxx"), getApplicationId(), + ClientSLgSession.class, null); + } finally { + try { + configStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + // ----------- delegate methods so + + public void start() throws IllegalDiameterStateException, InternalException { + stack.start(); + } + + public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException { + stack.start(mode, timeOut, timeUnit); + } + + public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException { + stack.stop(timeOut, timeUnit, disconnectCause); + } + + public void stop(int disconnectCause) { + stack.stop(disconnectCause); + } + + // ------- def methods, to fail :) + + public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, + RouteException, OverloadException { + fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer) throws InternalException, + IllegalDiameterStateException, RouteException, OverloadException { + fail("Received \"LRA\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocationRequest request, ProvideLocationAnswer answer) throws InternalException, + IllegalDiameterStateException, RouteException, OverloadException { + fail("Received \"PLA\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + // ----------- conf parts + + public String getSessionId() { + return this.clientSLgSession.getSessionId(); + } + + public ClientSLgSession getSession() { + return this.clientSLgSession; + } + + // Attributes for Location Report Request (LRR) + protected abstract String getUserName(); // IE: IMSI + protected abstract byte[] getMSISDN(); + protected abstract String getIMEI(); + protected abstract String getLCSNameString(); + protected abstract int getLCSFormatIndicator(); + protected abstract int getLCSQoSClass(); + protected abstract long getLSCServiceTypeId(); + protected abstract long getDeferredLocationType(); + protected abstract byte[] getLCSReferenceNumber(); + protected abstract java.net.InetAddress getGMLCAddress(); + protected abstract long getReportingAmount(); + protected abstract long getReportingInterval(); + protected abstract int getLocationEvent(); + protected abstract byte[] getLocationEstimate(); + protected abstract int getAccuracyFulfilmentIndicator(); + protected abstract long getAgeOfLocationEstimate(); + protected abstract byte[] getVelocityEstimate(); + protected abstract byte[] getEUTRANPositioningData(); + protected abstract byte[] getECGI(); + protected abstract byte[] getGERANPositioningData(); + protected abstract byte[] getGERANGANSSPositioningData(); + protected abstract byte[] getCellGlobalIdentity(); + protected abstract byte[] getUTRANPositioningData(); + protected abstract byte[] getUTRANGANSSPositioningData(); + protected abstract byte[] getServiceAreaIdentity(); + protected abstract int getPseudonymIndicator(); + protected abstract byte[] getSGSNNumber(); + protected abstract String getSGSNName(); + protected abstract String getSGSNRealm(); + protected abstract String getMMEName(); + protected abstract String getMMERealm(); + protected abstract byte[] getMSCNumber(); + protected abstract String get3GPPAAAServerName(); + protected abstract long getLCSCapabilitiesSets(); + protected abstract long getLRRFLags(); + protected abstract long getTerminationCause(); + protected abstract long getCellPortionId(); + protected abstract byte[] get1xRTTRCID(); + protected abstract String getCivicAddress(); + protected abstract long getBarometricPressure(); + + // ----------- 3GPP TS 29.172 reference + + protected LocationReportRequest createLRR(ClientSLgSession slgSession) throws Exception { + /* + < Location-Report-Request> ::= < Diameter Header: 8388621, REQ, PXY, 16777255 > + + < Session-Id > + [ Vendor-Specific-Application-Id ] + { Auth-Session-State } + { Origin-Host } + { Origin-Realm } + { Destination-Host } + { Destination-Realm } + { Location-Event } + [ LCS-EPS-Client-Name ] + [ User-Name ] + [ MSISDN] + [ IMEI ] + [ Location-Estimate ] + [ Accuracy-Fulfilment-Indicator ] + [ Age-Of-Location-Estimate ] + [ Velocity-Estimate ] + [ EUTRAN-Positioning-Data ] + [ ECGI ] + [ GERAN-Positioning-Info ] + [ Cell-Global-Identity ] + [ UTRAN-Positioning-Info ] + [ Service-Area-Identity ] + [ LCS-Service-Type-ID ] + [ Pseudonym-Indicator ] + [ LCS-QoS-Class ] + [ Serving-Node ] + [ LRR-Flags ] + [ LCS-Reference-Number ] + [ Deferred-MT-LR-Data] + [ GMLC-Address ] + [ Periodic-LDR-Information ] + [ ESMLC-Cell-Info ] + [ 1xRTT-RCID ] + [ Civic-Address ] + [ Barometric-Pressure ] + *[ Supported-Features ] + *[ AVP ] + *[ Proxy-Info ] + *[ Route-Record ] + + */ + // Create LocationReportRequest + LocationReportRequest lrr = new LocationReportRequestImpl(slgSession.getSessions().get(0).createRequest(LocationReportRequest.code, getApplicationId(), + getServerRealmName())); + // < Location-Report-Request> ::= < Diameter Header: 8388621, REQ, PXY, 16777255 > + + AvpSet reqSet = lrr.getMessage().getAvps(); + + if (reqSet.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) { + AvpSet vendorSpecificApplicationId = reqSet.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false); + // 1* [ Vendor-Id ] + vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true); + // 0*1{ Auth-Application-Id } + vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true); + } + + // { Auth-Session-State } + if (reqSet.getAvp(Avp.AUTH_SESSION_STATE) == null) { + reqSet.addAvp(Avp.AUTH_SESSION_STATE, 1); + } + + // { Origin-Host } + reqSet.removeAvp(Avp.ORIGIN_HOST); + reqSet.addAvp(Avp.ORIGIN_HOST, getClientURI(), true); + + // { Location-Event } + int locationEvent = getLocationEvent(); + if (locationEvent != -1){ + reqSet.addAvp(Avp.LOCATION_EVENT, locationEvent, 10415, true, false); + } + + // { LCS-EPS-Client-Name } + AvpSet lcsEPSClientName = reqSet.addGroupedAvp(Avp.LCS_EPS_CLIENT_NAME, 10415, false, false); + String lcsNameString = getLCSNameString(); + int lcsFormatIndicator = getLCSFormatIndicator(); + + if (lcsNameString != null){ + lcsEPSClientName.addAvp(Avp.LCS_NAME_STRING, lcsNameString, 10415, false, false, false); + } + if (lcsFormatIndicator != -1){ + lcsEPSClientName.addAvp(Avp.LCS_FORMAT_INDICATOR, lcsFormatIndicator, 10415, false, false); + } + + // [ User-Name ] IE: IMSI + String userName = getUserName(); + if (userName != null) { + reqSet.addAvp(Avp.USER_NAME, userName, 10415, true, false, false); + } + + // [ MSISDN ] + byte[] msisdn = getMSISDN(); + if (msisdn != null){ + reqSet.addAvp(Avp.MSISDN, msisdn, 10415, true, false); + } + + // [ IMEI ] + String imei = getIMEI(); + if (imei != null){ + reqSet.addAvp(Avp.TGPP_IMEI, imei, 10415, false, false, false); + } + + // [ Location-Estimate ] + byte[] locationEstimate = getLocationEstimate(); + if (locationEstimate != null){ + reqSet.addAvp(Avp.LOCATION_ESTIMATE, locationEstimate, 10415, true, false); + } + + // [ Accuracy-Fulfilment-Indicator ] + int accuracyFulfilmentIndicator = getAccuracyFulfilmentIndicator(); + if (accuracyFulfilmentIndicator != -1){ + reqSet.addAvp(Avp.ACCURACY_FULFILMENT_INDICATOR, accuracyFulfilmentIndicator, 10415, false, false); + } + + // [ Age-Of-Location-Estimate ] + long ageOfLocationEstimate = getAgeOfLocationEstimate(); + if (ageOfLocationEstimate != -1){ + reqSet.addAvp(Avp.AGE_OF_LOCATION_ESTIMATE, ageOfLocationEstimate, 10415, false, false, true); + } + + // [ Velocity-Estimate ] + byte[] velocityEstimate = getVelocityEstimate(); + if (velocityEstimate != null){ + reqSet.addAvp(Avp.VELOCITY_ESTIMATE, velocityEstimate, 10415, false, false); + } + + // [ EUTRAN-Positioning-Data ] + byte[] eutranPositioningData = getEUTRANPositioningData(); + if (eutranPositioningData != null){ + reqSet.addAvp(Avp.EUTRAN_POSITIONING_DATA, eutranPositioningData, 10415, false, false); + } + + // [ ECGI ] + byte[] ecgi = getECGI(); + if (ecgi != null){ + reqSet.addAvp(Avp.ECGI, ecgi, 10415, false, false); + } + + // [ GERAN-Positioning-Info ] + AvpSet geranPositioningInfo = reqSet.addGroupedAvp(Avp.GERAN_POSITIONING_INFO, 10415, false, false); + byte[] geranPositioningData = getGERANPositioningData(); + byte[] geranGanssPositioningData = getGERANGANSSPositioningData(); + + if (geranPositioningData != null){ + geranPositioningInfo.addAvp(Avp.GERAN_POSITIONING_DATA, geranPositioningData, 10415, false, false); + } + if (geranGanssPositioningData != null){ + geranPositioningInfo.addAvp(Avp.GERAN_GANSS_POSITIONING_DATA, geranGanssPositioningData, 10415, false, false); + } + + // [ Cell-Global-Identity ] + byte[] cellGlobalIdentity = getCellGlobalIdentity(); + if (cellGlobalIdentity != null){ + reqSet.addAvp(Avp.CELL_GLOBAL_IDENTITY, cellGlobalIdentity, 10415, false, false); + } + + // [ UTRAN-Positioning-Info ] + AvpSet utranPositioningInfo = reqSet.addGroupedAvp(Avp.UTRAN_POSITIONING_INFO, 10415, false, false); + byte[] utranPositioningData = getUTRANPositioningData(); + byte[] utranGanssPositioningData = getUTRANGANSSPositioningData(); + + if (utranPositioningData != null){ + utranPositioningInfo.addAvp(Avp.UTRAN_POSITIONING_DATA, utranPositioningData, 10415, false, false); + } + if (utranGanssPositioningData != null){ + utranPositioningInfo.addAvp(Avp.UTRAN_GANSS_POSITIONING_DATA, utranGanssPositioningData, 10415, false, false); + } + + // [ Service-Area-Identity ] + byte[] serviceAreaIdentity = getServiceAreaIdentity(); + if (serviceAreaIdentity != null){ + reqSet.addAvp(Avp.SERVICE_AREA_IDENTITY, serviceAreaIdentity, 10415, false, false); + } + + // [ LCS-Service-Type-ID ] + long lscServiceTypeId = getLSCServiceTypeId(); + if (lscServiceTypeId != -1){ + reqSet.addAvp(Avp.LCS_SERVICE_TYPE_ID, lscServiceTypeId, 10415, false, false, true); + } + + // [ Pseudonym-Indicator ] + int pseudonymIndicator = getPseudonymIndicator(); + if (pseudonymIndicator != -1){ + reqSet.addAvp(Avp.PSEUDONYM_INDICATOR, pseudonymIndicator, 10415, false, false); + } + + // [ LCS-QoS-Class ] + int lcsQoSClass = getLCSQoSClass(); + if (lcsQoSClass != -1){ + reqSet.addAvp(Avp.LCS_QOS_CLASS, lcsQoSClass, 10415, false, false); + } + + // [ Serving-Node ] IE: Target Serving Node Identity +/* + Serving-Node ::= + [ SGSN-Number ] + [ SGSN-Name ] + [ SGSN-Realm ] + [ MME-Name ] + [ MME-Realm ] + [ MSC-Number ] + [ 3GPP-AAA-Server-Name ] + [ LCS-Capabilities-Sets ] + [ GMLC-Address ] + *[AVP] + +*/ + AvpSet servingNode = reqSet.addGroupedAvp(Avp.SERVING_NODE, 10415, true, false); + byte[] sgsnNumber = getSGSNNumber(); + String sgsnName= getSGSNName(); + String sgsnRealm = getSGSNRealm(); + String mmeName = getMMEName(); + String mmeRealm = getMMERealm(); + byte[] mscNumber = getMSCNumber(); + String tgppAAAServerName= get3GPPAAAServerName(); + long lcsCapabilitiesSet = getLCSCapabilitiesSets(); + java.net.InetAddress gmlcAddress = getGMLCAddress(); + + if (sgsnNumber != null){ + servingNode.addAvp(Avp.SGSN_NUMBER, sgsnNumber, 10415, false, false); + } + if (sgsnName != null){ + servingNode.addAvp(Avp.SGSN_NAME, sgsnName, 10415, false, false, false); + } + if (sgsnRealm != null){ + servingNode.addAvp(Avp.SGSN_REALM, sgsnRealm, 10415, false, false, false); + } + if (mmeName != null){ + servingNode.addAvp(Avp.MME_NAME, mmeName, 10415, false, false, false); + } + if (mmeRealm != null){ + servingNode.addAvp(Avp.MME_REALM, mmeRealm, 10415, false, false, false); + } + if (mscNumber != null){ + servingNode.addAvp(Avp.MSC_NUMBER, mscNumber, 10415, false, false); + } + if (tgppAAAServerName != null){ + servingNode.addAvp(Avp.TGPP_AAA_SERVER_NAME, tgppAAAServerName, 10415, false, false, false); + } + if (lcsCapabilitiesSet != -1){ + servingNode.addAvp(Avp.LCS_CAPABILITIES_SETS, lcsCapabilitiesSet, 10415, false, false, true); + } + if (gmlcAddress != null){ + servingNode.addAvp(Avp.GMLC_ADDRESS, gmlcAddress, 10415, false, false); + } + + // [ LRR-Flags ] + long lrrFlags = getLRRFLags(); + if (lrrFlags != -1){ + reqSet.addAvp(Avp.LRR_FLAGS, lrrFlags, 10415, false, false, true); + } + + // [ LCS-Reference-Number ] + byte[] lcsReferenceNumber = getLCSReferenceNumber(); + if (lcsReferenceNumber != null){ + reqSet.addAvp(Avp.LCS_REFERENCE_NUMBER, lcsReferenceNumber, 10415, true, false); + } + + // [ Deferred-MT-LR-Data] + AvpSet deferredMTLRData = reqSet.addGroupedAvp(Avp.DEFERRED_MT_LR_DATA, 10415, false, false); + long deferredLocationType = getDeferredLocationType(); + long terminationCause = getTerminationCause(); + + if (deferredLocationType != -1){ + deferredMTLRData.addAvp(Avp.DEFERRED_LOCATION_TYPE, deferredLocationType, 10415, false, false, true); + } + if (terminationCause != -1){ + deferredMTLRData.addAvp(Avp.TERMINATION_CAUSE_LCS, terminationCause, 10415, false, false, true); + } + + // [ GMLC-Address ] + // attribute already defined for grouped AVP Serving Node + if (gmlcAddress != null){ + reqSet.addAvp(Avp.GMLC_ADDRESS, gmlcAddress, 10415, false, false); + } + + //[ Periodic-LDR-Information ] +/* +Periodic-LDR-Info ::= + { Reporting-Amount } + { Reporting-Interval } + *[ AVP ] +Reporting-Interval x Rreporting-Amount shall not exceed 8639999 (99 days, 23 hours, 59 minutes and 59 seconds) +for compatibility with OMA MLP and RLP. +*/ + AvpSet periodicLDRInfo = reqSet.addGroupedAvp(Avp.PERIODIC_LDR_INFORMATION, 10415, false, false); + long reportingAmount = getReportingAmount(); + long reportingInterval = getReportingInterval(); + + if (reportingAmount != -1){ + periodicLDRInfo.addAvp(Avp.REPORTING_AMOUNT, reportingAmount, 10415, false, false, true); + } + if (reportingInterval != -1){ + periodicLDRInfo.addAvp(Avp.REPORTING_INTERVAL, reportingInterval, 10415, false, false, true); + } + + // [ ESMLC-Cell-Info ] +/* + ESMLC-Cell-Info ::= + [ ECGI ] + [ Cell-Portion-ID ] + *[ AVP ] +*/ + AvpSet esmlcCellInfo = reqSet.addGroupedAvp(Avp.ESMLC_CELL_INFO, 10415, false, false); + // ECGI attribute already defined + long cellPortionId = getCellPortionId(); + + if (ecgi != null){ + esmlcCellInfo.addAvp(Avp.ECGI, ecgi, 10415, false, false); + } + if (cellPortionId != -1){ + esmlcCellInfo.addAvp(Avp.CELL_PORTION_ID, cellPortionId, 10415, false, false, true); + } + + // [ 1xRTT-RCID ] + byte[] onexRTTRCID = get1xRTTRCID(); + if (onexRTTRCID != null){ + reqSet.addAvp(Avp.ONEXRTT_RCID, onexRTTRCID, 10415, false, false); + } + + // [ Civic-Address ] + String civicAddress = getCivicAddress(); + if (civicAddress != null){ + reqSet.addAvp(Avp.CIVIC_ADDRESS, civicAddress, 10415, false, false, false); + } + + // [ Barometric-Pressure ] + long barometricPressure = getBarometricPressure(); + if (barometricPressure != -1){ + reqSet.addAvp(Avp.BAROMETRIC_PRESSURE, barometricPressure, 10415, false, false, true); + } + + return lrr; + } +} + diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractDeferredServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractDeferredServer.java new file mode 100644 index 000000000..974f269cd --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractDeferredServer.java @@ -0,0 +1,246 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg; + +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpSet; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.Mode; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.ServerSLgSessionListener; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.slg.LocationReportAnswerImpl; +import org.jdiameter.common.impl.app.slg.SLgSessionFactoryImpl; +import org.mobicents.diameter.stack.functional.TBase; + +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +/** + * + * @author Fernando Mendioroz + * + */ +public abstract class AbstractDeferredServer extends TBase implements ServerSLgSessionListener { + + // NOTE: implementing NetworkReqListener since its required for stack to + // know we support it... ech. + + protected ServerSLgSession serverSLgSession; + + public void init(InputStream configStream, String clientID) throws Exception { + try { + super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777255)); + SLgSessionFactoryImpl slgSessionFactory = new SLgSessionFactoryImpl(this.sessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLgSession.class, slgSessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLgSession.class, slgSessionFactory); + slgSessionFactory.setServerSessionListener(this); + } finally { + try { + configStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + // ----------- delegate methods so + + public void start() throws IllegalDiameterStateException, InternalException { + stack.start(); + } + + public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException { + stack.start(mode, timeOut, timeUnit); + } + + public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException { + stack.stop(timeOut, timeUnit, disconnectCause); + } + + public void stop(int disconnectCause) { + stack.stop(disconnectCause); + } + + public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, + RouteException, + OverloadException { + fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request) throws InternalException, IllegalDiameterStateException, + RouteException, OverloadException { + fail("Received \"LRR\" event, request[" + request + "], on session[" + session + "]", null); + } + // -------- conf + + public String getSessionId() { + return this.serverSLgSession.getSessionId(); + } + + public void fetchSession(String sessionId) throws InternalException { + this.serverSLgSession = stack.getSession(sessionId, ServerSLgSession.class); + } + + public ServerSLgSession getSession() { + return this.serverSLgSession; + } + + // Attributes for Location Report Answer (LRA) + protected abstract java.net.InetAddress getGMLCAddress(); + protected abstract long getLRAFLags(); + protected abstract int getPrioritizedListIndicator(); + protected abstract byte[] getVisitedPLMNId(); + protected abstract int getPeriodicLocationSupportIndicator(); + protected abstract byte[] getLCSReferenceNumber(); + + // ----------- 3GPP TS 29.172 reference + + public LocationReportAnswer createLRA(LocationReportRequest lrr, long resultCode) throws Exception { + /* + < Location-Report-Answer > ::= < Diameter Header: 8388621, PXY, 16777255> + + < Session-Id > + [ Vendor-Specific-Application-Id ] + [ Result-Code ] + [ Experimental-Result ] + { Auth-Session-State } + { Origin-Host } + { Origin-Realm } + [ GMLC-Address ] + [ LRA-Flags ] + [ Reporting-PLMN-List ] + [ LCS-Reference-Number ] + *[ Supported-Features ] + *[ AVP ] + *[ Failed-AVP ] + *[ Proxy-Info ] + *[ Route-Record ] + + */ + LocationReportAnswer lra = new LocationReportAnswerImpl((Request) lrr.getMessage(), resultCode); + + AvpSet reqSet = lrr.getMessage().getAvps(); + AvpSet set = lra.getMessage().getAvps(); + set.removeAvp(Avp.DESTINATION_HOST); + set.removeAvp(Avp.DESTINATION_REALM); + set.addAvp(reqSet.getAvp(Avp.AUTH_APPLICATION_ID)); + + // { Vendor-Specific-Application-Id } + if (set.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) { + AvpSet vendorSpecificApplicationId = set.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false); + // 1* [ Vendor-Id ] + vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true); + // 0*1{ Auth-Application-Id } + vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true); + } + // [ Result-Code ] + // [ Experimental-Result ] + // { Auth-Session-State } + if (set.getAvp(Avp.AUTH_SESSION_STATE) == null) { + set.addAvp(Avp.AUTH_SESSION_STATE, 1); + } + + //[ GMLC-Address ] + java.net.InetAddress gmlcAddress = getGMLCAddress(); + if (gmlcAddress != null){ + set.addAvp(Avp.GMLC_ADDRESS, gmlcAddress, 10415, false, false); + } + + // [ LRA-Flags ] + long lraFlags = getLRAFLags(); + if (lraFlags != -1){ + set.addAvp(Avp.LRA_FLAGS, lraFlags, 10415, false, false, true); + } + + //[ Reporting-PLMN-List ] +/* + Reporting-PLMN-List ::= + 1*20{ PLMN-ID-List } + [ Prioritized-List-Indicator ] + *[ AVP ] + + PLMN-ID-List ::= + { Visited-PLMN-Id } + [ Periodic-Location-Support-Indicator ] + *[ AVP ] +*/ + AvpSet reportingPLMNList = set.addGroupedAvp(Avp.REPORTING_PLMN_LIST, 10415, false, false); + int prioritizedListIndicator = getPrioritizedListIndicator(); + AvpSet plmnIdList = set.addGroupedAvp(Avp.PLMN_ID_LIST, 10415, false, false); + byte[] visitedPLMNId = getVisitedPLMNId(); + int periodicLocationSupportIndicator = getPeriodicLocationSupportIndicator(); + + if (prioritizedListIndicator != -1){ + reportingPLMNList.addAvp(Avp.PRIORITIZED_LIST_INDICATOR, prioritizedListIndicator, 10415, false, false); + } + if (plmnIdList != null){ + reportingPLMNList.addAvp(plmnIdList); + } + if (visitedPLMNId != null){ + plmnIdList.addAvp(Avp.VISITED_PLMN_ID, visitedPLMNId, 10415, false, false); + } + if (periodicLocationSupportIndicator != -1){ + plmnIdList.addAvp(Avp.PERIODIC_LOCATION_SUPPORT_INDICATOR, periodicLocationSupportIndicator, 10415, false, false); + } + + // [ LCS-Reference-Number ] + byte[] lcsReferenceNumber = getLCSReferenceNumber(); + if (lcsReferenceNumber != null){ + set.addAvp(Avp.LCS_REFERENCE_NUMBER, lcsReferenceNumber, 10415, true, false); + } + + return lra; + } +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractImmediateClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractImmediateClient.java new file mode 100644 index 000000000..06c06dd13 --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractImmediateClient.java @@ -0,0 +1,473 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg; + +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpSet; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.Mode; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ClientSLgSessionListener; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.slg.ProvideLocationRequestImpl; +import org.jdiameter.common.impl.app.slg.SLgSessionFactoryImpl; +import org.mobicents.diameter.stack.functional.TBase; + +/** + * + *@author Fernando Mendioroz + * + */ +public abstract class AbstractImmediateClient extends TBase implements ClientSLgSessionListener { + + // NOTE: implementing NetworkReqListener since its required for stack to + // know we support it... ech. + + protected ClientSLgSession clientSLgSession; + + public void init(InputStream configStream, String clientID) throws Exception { + try { + super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777255)); + SLgSessionFactoryImpl sLgSessionFactory = new SLgSessionFactoryImpl(this.sessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLgSession.class, sLgSessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLgSession.class, sLgSessionFactory); + + sLgSessionFactory .setClientSessionListener(this); + + this.clientSLgSession = ((ISessionFactory) this.sessionFactory).getNewAppSession(this.sessionFactory.getSessionId("xx-SLg-TESTxx"), getApplicationId(), + ClientSLgSession.class, null); + } finally { + try { + configStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + // ----------- delegate methods so + + public void start() throws IllegalDiameterStateException, InternalException { + stack.start(); + } + + public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException { + stack.start(mode, timeOut, timeUnit); + } + + public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException { + stack.stop(timeOut, timeUnit, disconnectCause); + } + + public void stop(int disconnectCause) { + stack.stop(disconnectCause); + } + + // ------- def methods, to fail :) + + public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, + RouteException, OverloadException { + fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocationRequest request, ProvideLocationAnswer answer) throws InternalException, + IllegalDiameterStateException, RouteException, OverloadException { + fail("Received \"PLA\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer) throws InternalException, + IllegalDiameterStateException, RouteException, OverloadException { + fail("Received \"LRA\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + // ----------- conf parts + + public String getSessionId() { + return this.clientSLgSession.getSessionId(); + } + + public ClientSLgSession getSession() { + return this.clientSLgSession; + } + + // Attributes for Provide Location Request (PLR) + protected abstract int getSLgLocationType(); + protected abstract String getUserName(); // IE: IMSI + protected abstract byte[] getMSISDN(); + protected abstract String getIMEI(); + protected abstract String getLCSNameString(); + protected abstract int getLCSFormatIndicator(); + protected abstract int getLCSClientType(); + protected abstract String getLCSRequestorIdString(); + protected abstract int getReqLCSFormatIndicator(); + protected abstract long getLCSPriority(); + protected abstract int getLCSQoSClass(); + protected abstract long getHorizontalAccuracy(); + protected abstract long getVerticalAccuracy(); + protected abstract int getVerticalRequested(); + protected abstract int getResponseTime(); + protected abstract int getVelocityRequested(); + protected abstract long getSupportedGADShapes(); + protected abstract long getLSCServiceTypeId(); + protected abstract String getLCSCodeword(); + protected abstract String getServiceSelection(); // IE: APN + protected abstract int getLCSPrivacyCheckSession(); + protected abstract int getLCSPrivacyCheckNonSession(); + protected abstract long getDeferredLocationType(); + protected abstract byte[] getLCSReferenceNumber(); + protected abstract int getOccurrenceInfo(); + protected abstract long getIntervalTime(); + protected abstract long getAreaType(); + protected abstract byte[] getAreaIdentification(); + protected abstract java.net.InetAddress getGMLCAddress(); + protected abstract long getPLRFLags(); + protected abstract long getReportingAmount(); + protected abstract long getReportingInterval(); + protected abstract int getPrioritizedListIndicator(); + protected abstract byte[] getVisitedPLMNId(); + protected abstract int getPeriodicLocationSupportIndicator(); + + // ----------- 3GPP TS 29.172 reference + + protected ProvideLocationRequest createPLR(ClientSLgSession slgSession) throws Exception { + /* + < Provide-Location-Request> ::= < Diameter Header: 8388620, REQ, PXY, 16777255 > + + < Session-Id > + [ Vendor-Specific-Application-Id ] + { Auth-Session-State } + { Origin-Host } + { Origin-Realm } + { Destination-Host } + { Destination-Realm } + { SLg-Location-Type } + [ User-Name ] + [ MSISDN ] + [ IMEI ] + { LCS-EPS-Client-Name } + { LCS-Client-Type } + [ LCS-Requestor-Name ] + [ LCS-Priority ] + [ LCS-QoS ] + [ Velocity-Requested ] + [ LCS-Supported-GAD-Shapes ] + [ LCS-Service-Type-ID ] + [ LCS-Codeword ] + [ LCS-Privacy-Check-Non-Session ] + [ LCS-Privacy-Check-Session ] + [ Service-Selection ] + [ Deferred-Location-Type ] + [ PLR-Flags ] + *[ Supported-Features ] + *[ AVP ] + *[ Proxy-Info ] + *[ Route-Record ] + Note: plus all extra AVPs defined in Table 6.2.2-1: Provide Subscriber Location Request, i.e. + [ LCS-Reference-Number ] + [ Area-Event-Info ] + [ GMLC-Address ] + [ Periodic-LDR-Information ] + [ Reporting-PLMN-List ] + */ + // Create ProvideLocationRequest + ProvideLocationRequest plr = new ProvideLocationRequestImpl(slgSession.getSessions().get(0).createRequest(ProvideLocationRequest.code, getApplicationId(), + getServerRealmName())); + // < Provide-Location-Request> ::= < Diameter Header: 8388620, REQ, PXY, 16777255 > + + AvpSet reqSet = plr.getMessage().getAvps(); + + if (reqSet.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) { + AvpSet vendorSpecificApplicationId = reqSet.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false); + // 1* [ Vendor-Id ] + vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true); + // 0*1{ Auth-Application-Id } + vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true); + } + + // { Auth-Session-State } + if (reqSet.getAvp(Avp.AUTH_SESSION_STATE) == null) { + reqSet.addAvp(Avp.AUTH_SESSION_STATE, 1); + } + + // { Origin-Host } + reqSet.removeAvp(Avp.ORIGIN_HOST); + reqSet.addAvp(Avp.ORIGIN_HOST, getClientURI(), true); + + + // { SLg-Location-Type } + int slgLocationType = getSLgLocationType(); + if (slgLocationType != -1){ + reqSet.addAvp(Avp.SLG_LOCATION_TYPE, slgLocationType, 10415, true, false); + } + + // [ User-Name ] IE: IMSI + String userName = getUserName(); + if (userName != null) { + reqSet.addAvp(Avp.USER_NAME, userName, 10415, true, false, false); + } + + // [ MSISDN ] + byte[] msisdn = getMSISDN(); + if (msisdn != null){ + reqSet.addAvp(Avp.MSISDN, msisdn, 10415, true, false); + } + + // [ IMEI ] + String imei = getIMEI(); + if (imei != null){ + reqSet.addAvp(Avp.TGPP_IMEI, imei, 10415, false, false, false); + } + + // { LCS-EPS-Client-Name } + AvpSet lcsEPSClientName = reqSet.addGroupedAvp(Avp.LCS_EPS_CLIENT_NAME, 10415, false, false); + String lcsNameString = getLCSNameString(); + int lcsFormatIndicator = getLCSFormatIndicator(); + + if (lcsNameString != null){ + lcsEPSClientName.addAvp(Avp.LCS_NAME_STRING, lcsNameString, 10415, false, false, false); + } + if (lcsFormatIndicator != -1){ + lcsEPSClientName.addAvp(Avp.LCS_FORMAT_INDICATOR, lcsFormatIndicator, 10415, false, false); + } + + // { LCS-Client-Type } + int lcsClientType = getLCSClientType(); + if (lcsClientType != -1){ + reqSet.addAvp(Avp.LCS_CLIENT_TYPE, lcsClientType, 10415, false, false); + } + + // [ LCS-Requestor-Name ] + AvpSet lcsRequestorName = reqSet.addGroupedAvp(Avp.LCS_REQUESTOR_NAME, 10415, false, false); + String lcsRequestorIdString = getLCSRequestorIdString(); + int reqLCSFormatIndicator = getReqLCSFormatIndicator(); + + if (lcsRequestorIdString != null){ + lcsRequestorName.addAvp(Avp.LCS_REQUESTOR_ID_STRING, lcsRequestorIdString, 10415, false, false, false); + } + if (reqLCSFormatIndicator != -1){ + lcsRequestorName.addAvp(Avp.LCS_FORMAT_INDICATOR, reqLCSFormatIndicator, 10415, false, false); + } + + // [ LCS-Priority ] + long lcsPriority = getLCSPriority(); + if (lcsPriority != -1){ + reqSet.addAvp(Avp.LCS_PRIORITY, lcsPriority, 10415, false, false, true); + } + + // [ LCS-QoS ] + AvpSet lcsQoS = reqSet.addGroupedAvp(Avp.LCS_QOS, 10415, false, false); + int lcsQoSClass = getLCSQoSClass(); + long horizontalAccuracy = getHorizontalAccuracy(); + long verticalAccuracy = getVerticalAccuracy(); + int verticalRequested = getVerticalRequested(); + int responseTime = getResponseTime(); + + if (lcsQoSClass != -1){ + lcsQoS.addAvp(Avp.LCS_QOS_CLASS, lcsQoSClass, 10415, false, false); + } + if (horizontalAccuracy != -1){ + lcsQoS.addAvp(Avp.HORIZONTAL_ACCURACY, horizontalAccuracy, 10415, false, false, true); + } + if(verticalAccuracy != -1){ + lcsQoS.addAvp(Avp.VERTICAL_ACCURACY, verticalAccuracy, 10415, false, false, true); + } + if(verticalRequested != -1){ + lcsQoS.addAvp(Avp.VERTICAL_REQUESTED, verticalRequested, 10415, false, false); + } + if(responseTime != -1){ + lcsQoS.addAvp(Avp.RESPONSE_TIME, responseTime, 10415, false, false); + } + + // [ Velocity-Requested ] + int velocityRequested = getVelocityRequested(); + if (velocityRequested != -1){ + reqSet.addAvp(Avp.VELOCITY_REQUESTED, velocityRequested, 10415, false, false); + } + + // [ LCS-Supported-GAD-Shapes ] + long supportedGADShapes = getSupportedGADShapes(); + if (supportedGADShapes != -1){ + reqSet.addAvp(Avp.SUPPORTED_GAD_SHAPES, supportedGADShapes, 10415, false, false, true); + } + + // [ LCS-Service-Type-ID ] + long lscServiceTypeId = getLSCServiceTypeId(); + if (lscServiceTypeId != -1){ + reqSet.addAvp(Avp.LCS_SERVICE_TYPE_ID, lscServiceTypeId, 10415, true, false, true); + } + + // [ LCS-Codeword ] + String lcsCodeword = getLCSCodeword(); + if (lcsCodeword != null){ + reqSet.addAvp(Avp.LCS_CODEWORD, lcsCodeword, 10415, false, false, false); + } + + //[ Service-Selection ] + String serviceSelection = getServiceSelection(); // IE: APN + if (serviceSelection != null){ + reqSet.addAvp(Avp.SERVICE_SELECTION, serviceSelection, false, false, false); + } + + // [ LCS-Privacy-Check-Session ] // IE: Session-Related Privacy Check + AvpSet lcsPrivacyCheckSession = reqSet.addGroupedAvp(Avp.LCS_PRIVACY_CHECK_SESSION, 10415, false, false); + int lcsPrivacyCheck = getLCSPrivacyCheckSession(); + + if (lcsPrivacyCheck != -1){ + lcsPrivacyCheckSession.addAvp(Avp.LCS_PRIVACY_CHECK, lcsPrivacyCheck, 10415, false, false); + } + + // [ LCS-Privacy-Check-Non-Session ] // IE: Non-Session-Related Privacy Check + AvpSet lcsPrivacyCheckNonSession = reqSet.addGroupedAvp(Avp.LCS_PRIVACY_CHECK_SESSION, 10415, false, false); + int lcsPrivacyCheckNS = getLCSPrivacyCheckNonSession(); + + if (lcsPrivacyCheckNS != -1){ + lcsPrivacyCheckNonSession.addAvp(Avp.LCS_PRIVACY_CHECK, lcsPrivacyCheck, 10415, false, false); + } + + // [ Deferred-Location-Type ] + long deferredLocationType = getDeferredLocationType(); + if (deferredLocationType != -1){ + reqSet.addAvp(Avp.DEFERRED_LOCATION_TYPE, deferredLocationType, 10415, false, false, true); + } + + // [ LCS-Reference-Number ] + byte[] lcsReferenceNumber = getLCSReferenceNumber(); + if (lcsReferenceNumber != null){ + reqSet.addAvp(Avp.LCS_REFERENCE_NUMBER, lcsReferenceNumber, 10415, true, false); + } + + // [ Area-Event-Info ] +/* + Area-Event-Info AVP of type grouped, includes: + Area-Definition, Occurrence-Info, Interval-Time + Area-Definition AVP of type grouped, includes: + Area-Type, Area-Identification +*/ + AvpSet areaEventInfo = reqSet.addGroupedAvp(Avp.AREA_EVENT_INFO, 10415, false, false); + int occurrenceInfo = getOccurrenceInfo(); + long intervalTime = getIntervalTime(); + AvpSet areaDefinition =reqSet.addGroupedAvp(Avp.AREA_DEFINITION, 10415, false, false); + long areaType = getAreaType(); + byte[] areaIdentification = getAreaIdentification(); + + if (occurrenceInfo != -1){ + areaEventInfo.addAvp(Avp.OCCURRENCE_INFO, occurrenceInfo, 10415, false, false); + } + if (intervalTime != -1){ + areaEventInfo.addAvp(Avp.INTERVAL_TIME, intervalTime, 10415, false, false, true); + } + if (areaDefinition != null){ + areaEventInfo.addAvp(areaDefinition); + } + if (areaType != -1){ + areaDefinition.addAvp(Avp.AREA_TYPE, areaType, 10415, false, false, true); + } + if (areaIdentification != null){ + areaDefinition.addAvp(Avp.AREA_IDENTIFICATION, areaIdentification, 10415, false, false); + } + + + //[ GMLC-Address ] + java.net.InetAddress gmlcAddress = getGMLCAddress(); + if (gmlcAddress != null){ + reqSet.addAvp(Avp.GMLC_ADDRESS, gmlcAddress, 10415, false, false); + } + + //[ PLR-Flags ] + long plrfLags = getPLRFLags(); + if (plrfLags != -1){ + reqSet.addAvp(Avp.PLR_FLAGS, plrfLags, 10415, false, false, true); + } + + // [ Periodic-LDR-Information ] + AvpSet periodicLDRInformation = reqSet.addGroupedAvp(Avp.AREA_EVENT_INFO, 10415, false, false); + long reportingAmount = getReportingAmount(); + long reportingInterval = getReportingInterval(); + + if (reportingAmount != -1){ + periodicLDRInformation.addAvp(Avp.REPORTING_AMOUNT, reportingAmount, 10415, false, false, true); + } + if (reportingInterval != -1){ + periodicLDRInformation.addAvp(Avp.REPORTING_INTERVAL, reportingInterval, 10415, false, false, true); + } + + // [ Reporting-PLMN-List ] + AvpSet reportingPLMNList = reqSet.addGroupedAvp(Avp.REPORTING_PLMN_LIST, 10415, false, false); + int prioritizedListIndicator = getPrioritizedListIndicator(); + AvpSet plmnIdList = reqSet.addGroupedAvp(Avp.PLMN_ID_LIST, 10415, false, false); + byte[] visitedPLMNId = getVisitedPLMNId(); + int periodicLocationSupportIndicator = getPeriodicLocationSupportIndicator(); + + if (prioritizedListIndicator != -1){ + reportingPLMNList.addAvp(Avp.PRIORITIZED_LIST_INDICATOR, prioritizedListIndicator, 10415, false, false); + } + if (plmnIdList != null){ + reportingPLMNList.addAvp(plmnIdList); + } + if (visitedPLMNId != null){ + plmnIdList.addAvp(Avp.VISITED_PLMN_ID, visitedPLMNId, 10415, false, false); + } + if (periodicLocationSupportIndicator != -1){ + plmnIdList.addAvp(Avp.PERIODIC_LOCATION_SUPPORT_INDICATOR, periodicLocationSupportIndicator, 10415, false, false); + } + + return plr; + } + +} + diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractImmediateServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractImmediateServer.java new file mode 100644 index 000000000..ca536bcbc --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/AbstractImmediateServer.java @@ -0,0 +1,388 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg; + +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpSet; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.Mode; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.ServerSLgSessionListener; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.slg.ProvideLocationAnswerImpl; +import org.jdiameter.common.impl.app.slg.SLgSessionFactoryImpl; +import org.mobicents.diameter.stack.functional.TBase; + +/** + * + * @author Fernando Mendioroz + * + */ +public abstract class AbstractImmediateServer extends TBase implements ServerSLgSessionListener { + + // NOTE: implementing NetworkReqListener since its required for stack to + // know we support it... ech. + + protected ServerSLgSession serverSLgSession; + + public void init(InputStream configStream, String clientID) throws Exception { + try { + super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777255)); + SLgSessionFactoryImpl slgSessionFactory = new SLgSessionFactoryImpl(this.sessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLgSession.class, slgSessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLgSession.class, slgSessionFactory); + slgSessionFactory.setServerSessionListener(this); + } finally { + try { + configStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + // ----------- delegate methods so + + public void start() throws IllegalDiameterStateException, InternalException { + stack.start(); + } + + public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException { + stack.start(mode, timeOut, timeUnit); + } + + public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException { + stack.stop(timeOut, timeUnit, disconnectCause); + } + + public void stop(int disconnectCause) { + stack.stop(disconnectCause); + } + + public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, + RouteException, + OverloadException { + fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) throws InternalException, IllegalDiameterStateException, + RouteException, OverloadException { + fail("Received \"PLR\" event, request[" + request + "], on session[" + session + "]", null); + } + // -------- conf + + public String getSessionId() { + return this.serverSLgSession.getSessionId(); + } + + public void fetchSession(String sessionId) throws InternalException { + this.serverSLgSession = stack.getSession(sessionId, ServerSLgSession.class); + } + + public ServerSLgSession getSession() { + return this.serverSLgSession; + } + + // Attributes for Provide Location Answer (PLA) + protected abstract byte[] getLocationEstimate(); + protected abstract int getAccuracyFulfilmentIndicator(); + protected abstract long getAgeOfLocationEstimate(); + protected abstract byte[] getVelocityEstimate(); + protected abstract byte[] getEUTRANPositioningData(); + protected abstract byte[] getECGI(); + protected abstract byte[] getGERANPositioningData(); + protected abstract byte[] getGERANGANSSPositioningData(); + protected abstract byte[] getCellGlobalIdentity(); + protected abstract byte[] getUTRANPositioningData(); + protected abstract byte[] getUTRANGANSSPositioningData(); + protected abstract byte[] getServiceAreaIdentity(); + protected abstract byte[] getSGSNNumber(); + protected abstract String getSGSNName(); + protected abstract String getSGSNRealm(); + protected abstract String getMMEName(); + protected abstract String getMMERealm(); + protected abstract byte[] getMSCNumber(); + protected abstract String get3GPPAAAServerName(); + protected abstract long getLCSCapabilitiesSets(); + protected abstract long getPLAFLags(); + protected abstract long getCellPortionId(); + protected abstract String getCivicAddress(); + protected abstract long getBarometricPressure(); + protected abstract java.net.InetAddress getGMLCAddress(); + + // ----------- 3GPP TS 29.172 reference + + public ProvideLocationAnswer createPLA(ProvideLocationRequest plr, long resultCode) throws Exception { + /* + < Provide-Location-Answer > ::= < Diameter Header: 8388620, PXY, 16777255 > + < Session-Id > + [ Vendor-Specific-Application-Id ] + [ Result-Code ] + [ Experimental-Result ] + { Auth-Session-State } + { Origin-Host } + { Origin-Realm } + [ Location-Estimate ] + [ Accuracy-Fulfilment-Indicator ] + [ Age-Of-Location-Estimate] + [ Velocity-Estimate ] + [ EUTRAN-Positioning-Data] + [ ECGI ] + [ GERAN-Positioning-Info ] + [ Cell-Global-Identity ] + [ UTRAN-Positioning-Info ] + [ Service-Area-Identity ] + [ Serving-Node ] + [ PLA-Flags ] + [ ESMLC-Cell-Info ] + [ Civic-Address ] + [ Barometric-Pressure ] + *[ Supported-Features ] + *[ AVP ] + *[ Failed-AVP ] + *[ Proxy-Info ] + *[ Route-Record ] + + */ + ProvideLocationAnswer pla = new ProvideLocationAnswerImpl((Request) plr.getMessage(), resultCode); + + AvpSet reqSet = plr.getMessage().getAvps(); + AvpSet set = pla.getMessage().getAvps(); + set.removeAvp(Avp.DESTINATION_HOST); + set.removeAvp(Avp.DESTINATION_REALM); + set.addAvp(reqSet.getAvp(Avp.AUTH_APPLICATION_ID)); + + // { Vendor-Specific-Application-Id } + if (set.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) { + AvpSet vendorSpecificApplicationId = set.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false); + // 1* [ Vendor-Id ] + vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true); + // 0*1{ Auth-Application-Id } + vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true); + } + // [ Result-Code ] + // [ Experimental-Result ] + // { Auth-Session-State } + if (set.getAvp(Avp.AUTH_SESSION_STATE) == null) { + set.addAvp(Avp.AUTH_SESSION_STATE, 1); + } + + // [ Location-Estimate ] + byte[] locationEstimate = getLocationEstimate(); + if (locationEstimate != null){ + set.addAvp(Avp.LOCATION_ESTIMATE, locationEstimate, 10415, true, false); + } + + // [ Accuracy-Fulfilment-Indicator ] + int accuracyFulfilmentIndicator = getAccuracyFulfilmentIndicator(); + if (accuracyFulfilmentIndicator != -1){ + set.addAvp(Avp.ACCURACY_FULFILMENT_INDICATOR, accuracyFulfilmentIndicator, 10415, false, false); + } + + // [ Age-Of-Location-Estimate ] + long ageOfLocationEstimate = getAgeOfLocationEstimate(); + if (ageOfLocationEstimate != -1){ + set.addAvp(Avp.AGE_OF_LOCATION_ESTIMATE, ageOfLocationEstimate, 10415, false, false, true); + } + + // [ Velocity-Estimate ] + byte[] velocityEstimate = getVelocityEstimate(); + if (velocityEstimate != null){ + set.addAvp(Avp.VELOCITY_ESTIMATE, velocityEstimate, 10415, false, false); + } + + // [ EUTRAN-Positioning-Data ] + byte[] eutranPositioningData = getEUTRANPositioningData(); + if (eutranPositioningData != null){ + set.addAvp(Avp.EUTRAN_POSITIONING_DATA, eutranPositioningData, 10415, false, false); + } + + // [ ECGI ] + byte[] ecgi = getECGI(); + if (ecgi != null){ + set.addAvp(Avp.ECGI, ecgi, 10415, false, false); + } + + // [ GERAN-Positioning-Info ] + AvpSet geranPositioningInfo = set.addGroupedAvp(Avp.GERAN_POSITIONING_INFO, 10415, false, false); + byte[] geranPositioningData = getGERANPositioningData(); + byte[] geranGanssPositioningData = getGERANGANSSPositioningData(); + + if (geranPositioningData != null){ + geranPositioningInfo.addAvp(Avp.GERAN_POSITIONING_DATA, geranPositioningData, 10415, false, false); + } + if (geranGanssPositioningData != null){ + geranPositioningInfo.addAvp(Avp.GERAN_GANSS_POSITIONING_DATA, geranGanssPositioningData, 10415, false, false); + } + + // [ Cell-Global-Identity ] + byte[] cellGlobalIdentity = getCellGlobalIdentity(); + if (cellGlobalIdentity != null){ + set.addAvp(Avp.CELL_GLOBAL_IDENTITY, cellGlobalIdentity, 10415, false, false); + } + + // [ UTRAN-Positioning-Info ] + AvpSet utranPositioningInfo = set.addGroupedAvp(Avp.UTRAN_POSITIONING_INFO, 10415, false, false); + byte[] utranPositioningData = getUTRANPositioningData(); + byte[] utranGanssPositioningData = getUTRANGANSSPositioningData(); + + if ( utranPositioningData != null){ + utranPositioningInfo.addAvp(Avp.UTRAN_POSITIONING_DATA, utranPositioningData, 10415, false, false); + } + if ( utranGanssPositioningData != null){ + utranPositioningInfo.addAvp(Avp.UTRAN_GANSS_POSITIONING_DATA, utranGanssPositioningData, 10415, false, false); + } + + // [ Service-Area-Identity ] + byte[] serviceAreaIdentity = getServiceAreaIdentity(); + if (serviceAreaIdentity != null){ + set.addAvp(Avp.SERVICE_AREA_IDENTITY, serviceAreaIdentity, 10415, false, false); + } + +// [ Serving-Node ] IE: Target Serving Node Identity +/* + Serving-Node ::= + [ SGSN-Number ] + [ SGSN-Name ] + [ SGSN-Realm ] + [ MME-Name ] + [ MME-Realm ] + [ MSC-Number ] + [ 3GPP-AAA-Server-Name ] + [ LCS-Capabilities-Sets ] + [ GMLC-Address ] + *[AVP] +*/ + AvpSet servingNode = set.addGroupedAvp(Avp.SERVING_NODE, 10415, false, false); + byte[] sgsnNumber = getSGSNNumber(); + String sgsnName= getSGSNName(); + String sgsnRealm = getSGSNRealm(); + String mmeName = getMMEName(); + String mmeRealm = getMMERealm(); + byte[] mscNumber = getMSCNumber(); + String tgppAAAServerName= get3GPPAAAServerName(); + long lcsCapabilitiesSet = getLCSCapabilitiesSets(); + java.net.InetAddress gmlcAddress = getGMLCAddress(); + + if (sgsnNumber != null){ + servingNode.addAvp(Avp.SGSN_NUMBER, sgsnNumber, 10415, false, false); + } + if (sgsnName != null){ + servingNode.addAvp(Avp.SGSN_NAME, sgsnName, 10415, false, false, false); + } + if (sgsnRealm != null){ + servingNode.addAvp(Avp.SGSN_REALM, sgsnRealm, 10415, false, false, false); + } + if (mmeName != null){ + servingNode.addAvp(Avp.MME_NAME, mmeName, 10415, false, false, false); + } + if (mmeRealm != null){ + servingNode.addAvp(Avp.MME_REALM, mmeRealm, 10415, false, false, false); + } + if (mscNumber != null){ + servingNode.addAvp(Avp.MSC_NUMBER, mscNumber, 10415, false, false); + } + if (tgppAAAServerName != null){ + servingNode.addAvp(Avp.TGPP_AAA_SERVER_NAME, tgppAAAServerName, 10415, false, false, false); + } + if (lcsCapabilitiesSet != -1){ + servingNode.addAvp(Avp.LCS_CAPABILITIES_SETS, lcsCapabilitiesSet, 10415, false, false, true); + } + if (gmlcAddress != null){ + servingNode.addAvp(Avp.GMLC_ADDRESS, gmlcAddress, 10415, false, false); + } + + // [ PLA-Flags ] + long plaFlags = getPLAFLags(); + if (plaFlags != -1){ + set.addAvp(Avp.PLA_FLAGS, plaFlags, 10415, false, false, true); + } + + // [ ESMLC-Cell-Info ] +/* + ESMLC-Cell-Info ::= + [ ECGI ] + [ Cell-Portion-ID ] + *[ AVP ] +*/ + AvpSet esmlcCellInfo = set.addGroupedAvp(Avp.ESMLC_CELL_INFO, 10415, false, false); + // ECGI attribute already defined + long cellPortionId = getCellPortionId(); + + if (ecgi != null){ + esmlcCellInfo.addAvp(Avp.ECGI, ecgi, 10415, false, false); + } + if (cellPortionId != -1){ + esmlcCellInfo.addAvp(Avp.CELL_PORTION_ID, cellPortionId, 10415, false, false, true); + } + + // [ Civic-Address ] + String civicAddress = getCivicAddress(); + if (civicAddress != null){ + set.addAvp(Avp.CIVIC_ADDRESS, civicAddress, 10415, false, false, false); + } + + // [ Barometric-Pressure ] + long barometricPressure = getBarometricPressure(); + if (barometricPressure != -1){ + set.addAvp(Avp.BAROMETRIC_PRESSURE, barometricPressure, 10415, false, false, true); + } + + return pla; + } + +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ClientLRR.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ClientLRR.java new file mode 100644 index 000000000..138cd1dd6 --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ClientLRR.java @@ -0,0 +1,527 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg.base; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.mobicents.diameter.stack.functional.Utils; +import org.mobicents.diameter.stack.functional.slg.AbstractDeferredClient; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ClientLRR extends AbstractDeferredClient { + + protected boolean receivedLRA; + protected boolean sentLRR; + + public ClientLRR() { + } + + public void sendLocationReportRequest() throws Exception { + LocationReportRequest lrr = super.createLRR(super.clientSLgSession); + super.clientSLgSession.sendLocationReportRequest(lrr); + Utils.printMessage(log, super.stack.getDictionary(), lrr.getMessage(), true); + this.sentLRR = true; + } + + /* (non-Javadoc) + * @see org.mobicents.diameter.stack.functional.slg.AbstractIDeferredClient#doLocationReportAnswerEvent( + * org.jdiameter.api.slg.ClientSLgSession, org.jdiameter.api.slg.events.LocationReportRequest, org.jdiameter.api.slg.events.LocationReportAnswer) + */ + + @Override + public void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), false); + + if (this.receivedLRA) { + fail("Received PLA more than once", null); + return; + } + this.receivedLRA = true; + } + + @Override + protected String getLCSNameString() { + String lcsNameString = "Restcomm Geolocation API"; + return lcsNameString; + } + + @Override + protected int getLCSFormatIndicator() { + /* + "0" = "LOGICAL_NAME" + "1" = "EMAIL_ADDRESS" + "2" = "MSISDN" + "3" = "URL" + "4" = "SIP_URL" + */ + int lcsFormatIndicator = 2; + return lcsFormatIndicator; + } + + @Override + protected String getUserName() { + // Information Element IMSI Mapped to AVP User-Name + String imsi = "748039876543210"; + return imsi; + } + + @Override + protected byte[] getMSISDN() { + String msisdnString = "59899077937"; + byte[] msisdn = msisdnString.getBytes(); + return msisdn; + } + + @Override + protected String getIMEI() { + String imei = "011714004661057"; + return imei; + } + + @Override + protected long getDeferredLocationType() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.36 + Bit Event Type Description + 0 UE-Available Any event in which the SGSN has established a contact with the UE. + 1 Entering-Into-Area An event where the UE enters a pre-defined geographical area. + 2 Leaving-From-Area An event where the UE leaves a pre-defined geographical area. + 3 Being-Inside-Area An event where the UE is currently within the pre-defined geographical area.For this event, + the value of Occurrence-Info AVP is always treated as set to “ONE_TIME_EVENT”. + 4 Periodic-LDR An event where a defined periodic timer expires in the UE and activates a location report or a location request. + */ + long deferredLocationType = 8; + return deferredLocationType; + } + + @Override + protected byte[] getLCSReferenceNumber() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.37 + The LCS-Reference-Number AVP is of type OctetString of length 1. It shall contain the reference number identifying the deferred location request. + */ + String lcsRefNumber = "4C4353353739"; + byte[] lcsRefNum = lcsRefNumber.getBytes(); + return lcsRefNum; + } + + @Override + protected java.net.InetAddress getGMLCAddress() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.7 + The GMLC-Address AVP is of type Address and shall contain the IPv4 or IPv6 address of H-GMLC or the V-GMLC associated with the serving node. + */ + try { + java.net.InetAddress gmlcAddress = java.net.InetAddress.getLocalHost(); + return gmlcAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected long getReportingAmount() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.46 + The Reporting-Amount AVP is of type Unsigned32 and it contains reporting frequency. Its minimum value shall be 1 and maximum value shall be 8639999. + */ + long reportingAmount = 8639910L; + return reportingAmount; + } + + @Override + protected long getReportingInterval() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.47 + The Interval-Time AVP is of type Unsigned32 and it contains reporting frequency. Its minimum value shall be 1 and maximum value shall be 8639999. + */ + long reportingInterval = 8639998L; + return reportingInterval; + } + + @Override + protected int getLocationEvent() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.20 + EMERGENCY_CALL_ORIGINATION (0) + EMERGENCY_CALL_RELEASE (1) + MO_LR (2) + EMERGENCY_CALL_HANDOVER (3) + DEFERRED_MT_LR_RESPONSE (4) + DEFERRED_MO_LR_TTTP_INITIATION (5) + DELAYED_LOCATION_REPORTING (6) + */ + int locationEvent = 4; + return locationEvent; + } + + @Override + protected byte[] getLocationEstimate() { + String locEstimate = "N43°38'19.39\" W116°14'28.86\""; + byte[] locationEstimate = locEstimate.getBytes(); + return locationEstimate; + } + + @Override + protected int getAccuracyFulfilmentIndicator() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.15 + REQUESTED_ACCURACY_FULFILLED (0) + REQUESTED_ACCURACY_NOT_FULFILLED (1) + */ + int accuracyFulfilmentIndicator = 0; + return accuracyFulfilmentIndicator; + } + + @Override + protected long getAgeOfLocationEstimate() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.19 + The Age-Of-Location-Estimate AVP is of type Unsigned32. + It indicates how long ago the location estimate was obtained in minutes, as indicated in 3GPP TS 29.002 [19]. + */ + long ageOfLocationEstimate = 374312L; + return ageOfLocationEstimate; + } + + @Override + protected byte[] getVelocityEstimate() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.17 + The Velocity-Estimate AVP is of type OctetString. + It is composed of 4 or more octets with an internal structure according to 3GPP TS 23.032 [3]. + */ + String vel = "210"; + byte[] velocityEstimate = vel.getBytes(); + return velocityEstimate; + } + + @Override + protected byte[] getEUTRANPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.18 + The EUTRAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "Positioning-Data" Information Element as defined in 3GPP TS 29.171 [7]. + */ + String eutran = "654E423435336C7465613233"; + byte[] eutranPositioningData = eutran.getBytes(); + return eutranPositioningData; + } + + @Override + protected byte[] getECGI() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.19 + The ECGI AVP is of type OctetString. It indicates the E-UTRAN Cell Global Identifier. + It is coded according to clause 8.21.5, in 3GPP TS 29.274 [8]. + */ + String eCgi = "654E4239343337"; + byte[] ecgi = eCgi.getBytes(); + return ecgi; + } + + @Override + protected byte[] getGERANPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.30 + The GERAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "Positioning Data" Information Element as defined in 3GPP TS 49.031 [20] + */ + String geran = "42545339343342534333"; + byte[] geranPositioningData = geran.getBytes(); + return geranPositioningData; + } + + @Override + protected byte[] getGERANGANSSPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.30 + The GERAN-GANSS-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "GANSS Positioning Data" Information Element as defined in 3GPP TS 49.031 [20] + */ + String geranGanss = "4254533733524E4331473433"; + byte[] geranGanssPositioningData = geranGanss.getBytes(); + return geranGanssPositioningData; + } + + @Override + protected byte[] getCellGlobalIdentity() { + String cgi = "9342784713907"; + byte[] CellGlobalIdentity = cgi.getBytes(); + return CellGlobalIdentity; + } + + @Override + protected byte[] getUTRANPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.33 + The UTRAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "positioningDataDiscriminator" and the "positioningDataSet" included in the + "positionData" Information Element as defined in 3GPP TS 25.413 [21]. + */ + String utran = "4E42393433524E4331"; + byte[] utranPositioningData = utran.getBytes(); + return utranPositioningData; + } + + @Override + protected byte[] getUTRANGANSSPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.33 + The UTRAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "positioningDataDiscriminator" and the "positioningDataSet" included in the + "positionData" Information Element as defined in 3GPP TS 25.413 [21]. + */ + String utranGanss = "4E42303331524E4335473433"; + byte[] utranGanssPositioningData = utranGanss.getBytes(); + return utranGanssPositioningData; + } + + @Override + protected byte[] getServiceAreaIdentity() { + /* + 3GPP TS 29.172 v13.0.0 -> 3GPP TS 29.272 + SAI shall contain the current service area of the target UE. The Service Area Identifier (SAI) is used to globally identify a service area. + This Information Element is applicable only when the UE is attached to UTRAN access and when the message is sent by the SGSN or combined MME/SGSN + */ + String sai = "service-area-umts-3"; + byte[] serviceAreaIdentity = sai.getBytes(); + return serviceAreaIdentity; + } + + @Override + protected long getLSCServiceTypeId() { + long lcsServiceTypeId = 234567012L; + return lcsServiceTypeId; + } + + @Override + protected int getPseudonymIndicator() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.21 + PSEUDONYM_NOT_REQUESTED (0) + PSEUDONYM_REQUESTED (1) + */ + int pseudonymIndicator = 0; + return pseudonymIndicator; + } + + @Override + protected int getLCSQoSClass() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.27 + ASSURED (0) + BEST EFFORT (1) + */ + int lcsQoSClass = 1; + return lcsQoSClass; + } + + @Override + protected byte[] getSGSNNumber() { + String sgsnNumString = "59899004501"; + byte[] sgsnNumber = sgsnNumString.getBytes(); + return sgsnNumber; + } + + @Override + protected String getSGSNName() { + String sgsnName = "SGSN01"; + return sgsnName; + } + + @Override + protected String getSGSNRealm() { + String sgsnRealm = "sgsn.restcomm.com"; + return sgsnRealm; + } + + @Override + protected String getMMEName() { + String mmeName = "MME710"; + return mmeName; + } + + @Override + protected String getMMERealm() { + String mmeRealm = "mme.restcomm.com"; + return mmeRealm; + } + + @Override + protected byte[] getMSCNumber() { + String mscNumString = "59899001207"; + byte[] mscNumber = mscNumString.getBytes(); + return mscNumber; + } + + @Override + protected String get3GPPAAAServerName() { + String tgppAAAServerName = "aaa.restcomm.com"; + return tgppAAAServerName; + } + + @Override + protected long getLCSCapabilitiesSets() { + long lcsCapabilitiesSets = 99900123L; + return lcsCapabilitiesSets; + } + + @Override + protected long getLRRFLags() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.35 + Bit Event Type Description + 0 Lgd/SLg-Indicator This bit, when set, indicates that the Location Report Request message is sent on the Lgd interface, + i.e. the source node is an SGSN (or a combined MME/SGSN to which the UE is attached via UTRAN or GERAN). + This bit, when cleared, indicates that the Location Report Request message is sent on the SLg interface, + i.e. the source node is an MME (or a combined MME/SGSN to which the UE is attached via E-UTRAN). + 1 MO-LR-ShortCircuit-Indicator This bit, when set, indicates that the MO-LR short circuit feature is used by the UE for + location estimate. This bit is applicable only when for deferred MT-LR procedure and + when the message is sent over Lgd interface. + 2 MO-LR-ShortCircuit-Requested This bit, when set, indicates that the UE is requesting to use MO-LR short circuit feature + for location estimate. + This bit is applicable only when periodic MO-LR TTTP procedure is initiated by the UE and when the + message is sent over Lgd interface. + */ + long lrrFlags = 1; + return lrrFlags; + } + + @Override + protected long getTerminationCause() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.55 + "Normal" 0 + "Error Undefined" 1 + "Internal Timeout" 2 + "Congestion" 3 + "MT_LR_Restart" 4 + "Privacy Violation" 5 + "Shape of Location Estimate Not Supported" 6 + "Subscriber Termination" 7 + "UE Termination" 8 + "Network Termination" 9 + */ + long terminationCause = 7; + return terminationCause; + } + + @Override + protected long getCellPortionId() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.58 + The Cell-Portion-ID AVP is of type Unsigned32. It indicates the current Cell Portion location of the target UE as provided by the E-SMLC. + It shall contain the value of the "Cell Portion ID" Information Element as defined in 3GPP TS 29.171 + */ + long cellPortionId = 349232432L; + return cellPortionId; + } + + @Override + protected byte[] get1xRTTRCID() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.59 + The 1xRTT-RCID AVP is of type OctetString. + It indicates the 1xRTT Reference Cell Id that consists of a Cell Identification Discriminator and a Cell Identification and shall be formatted + according to octets 3 through the end of the Cell Identifier element defined in subclause 4.2.17 in 3GPP2 A.S0014-D [22]. + The allowable cell discriminator values are "0000 0010", and "0000 0111". + */ + String oxrttrcid = "00000010"; + byte[] onexrttrcid = oxrttrcid.getBytes(); + return onexrttrcid; + } + + @Override + protected String getCivicAddress() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.61 + The Civic-Address AVP is of type UTF8String. + It contains the XML document carried in the "Civic Address" Information Element as defined in 3GPP TS 29.171. + */ + String civicAddress = "\n" + + " UK\n" + + " Devon\n" + + " Monkokehampton\n" + + " Deckport\n" + + " Cross\n" + + "\n" + + " 21451338\n" + + "\n" + + " "; // From IETF RFC 6848, Extended Civic Address Example + return civicAddress; + } + + @Override + protected long getBarometricPressure() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.62 + The Barometric-Pressure AVP is of type Unsigned32. + It contains the "Barometric Pressure" Information Element as defined in 3GPP TS 29.171. + */ + long barometricPressure = 101327L; + return barometricPressure; + } + + public boolean isReceivedLRA() { + return receivedLRA; + } + + public boolean isSentLRR() { + return sentLRR; + } +} + diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ClientPLR.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ClientPLR.java new file mode 100644 index 000000000..1718fc744 --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ClientPLR.java @@ -0,0 +1,516 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg.base; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.mobicents.diameter.stack.functional.Utils; +import org.mobicents.diameter.stack.functional.slg.AbstractImmediateClient; + +import static sun.jdbc.odbc.JdbcOdbcObject.hexStringToByteArray; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ClientPLR extends AbstractImmediateClient { + + protected boolean receivedPLA; + protected boolean sentPLR; + + public ClientPLR() { + } + + public void sendProvideLocationRequest() throws Exception { + ProvideLocationRequest plr = super.createPLR(super.clientSLgSession); + super.clientSLgSession.sendProvideLocationRequest(plr); + Utils.printMessage(log, super.stack.getDictionary(), plr.getMessage(), true); + this.sentPLR = true; + } + + /* (non-Javadoc) + * @see org.mobicents.diameter.stack.functional.slg.AbstractImmediateClient#doProvideLocationAnswerEvent( + * org.jdiameter.api.slg.ClientSLgSession, org.jdiameter.api.slg.events.ProvideLocationRequest, org.jdiameter.api.slg.events.ProvideLocationAnswer) + */ + @Override + public void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocationRequest request, ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), false); + + if (this.receivedPLA) { + fail("Received PLA more than once", null); + return; + } + this.receivedPLA = true; + } + + // PLR methods + + // { SLg-Location-Type } + protected int getSLgLocationType() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.2 + The SLg-Location-Type AVP is of type Enumerated. The following values are defined: + CURRENT_LOCATION (0) + CURRENT_OR_LAST_KNOWN_LOCATION (1) + INITIAL_LOCATION (2) + ACTIVATE_DEFERRED_LOCATION (3) + CANCEL_DEFERRED_LOCATION (4) + NOTIFICATION_VERIFICATION_ONLY (5) + */ + int slgLocationType = 0; + return slgLocationType; + } + + @Override + protected String getLCSNameString() { + String lcsNameString = "Restcomm Geolocation API"; + return lcsNameString; + } + + protected int getLCSFormatIndicator() { + /* + "0" = "LOGICAL_NAME" + "1" = "EMAIL_ADDRESS" + "2" = "MSISDN" + "3" = "URL" + "4" = "SIP_URL" + */ + int lcsFormatIndicator = 2; + return lcsFormatIndicator; + } + + @Override + protected String getUserName() { + // Information Element IMSI Mapped to AVP User-Name + String imsi = "748039876543210"; + return imsi; + } + + @Override + protected byte[] getMSISDN() { + String msisdnString = "59899077937"; + byte[] msisdn = msisdnString.getBytes(); + return msisdn; + } + + @Override + protected String getIMEI() { + String imei = "011714004661057"; + return imei; + } + + @Override + protected int getLCSClientType() { + /* + "0" = "EMERGENCY_SERVICES" + "1" = "VALUE_ADDED_SERVICES" + "2" = "PLMN_OPERATOR_SERVICES" + "3" = "LAWFUL_INTERCEPT_SERVICES" + */ + int lcsClientType = 1; + return lcsClientType; + } + + @Override + protected String getLCSRequestorIdString() { + String lcsRequestorIdString = "restcomm_geolocation_23"; + return lcsRequestorIdString; + } + + @Override + protected int getReqLCSFormatIndicator() { + /* + "0" = "LOGICAL_NAME" + "1" = "EMAIL_ADDRESS" + "2" = "MSISDN" + "3" = "URL" + "4" = "SIP_URL" + */ + int requestorLCSFormatIndicator = 3; + return requestorLCSFormatIndicator; + } + + @Override + protected long getLCSPriority() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.5 + The LCS-Priority AVP is of type Unsigned32. It indicates the priority of the location request. + The value 0 shall indicate the highest priority, and the value 1 shall indicate normal priority. + All other values shall be treated as 1 (normal priority). For details, refer to 3GPP TS 22.071. + */ + int lcsPriority = 1; + return lcsPriority; + } + + @Override + protected int getLCSQoSClass() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.27 + ASSURED (0) + BEST EFFORT (1) + */ + int lcsQoSClass = 1; + return lcsQoSClass; + } + + @Override + protected long getHorizontalAccuracy() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.7 + The Horizontal-Accuracy AVP is of type Unsigned32. Bits 6-0 corresponds to Uncertainty Code defined in 3GPP TS 23.032 [3]. + The horizontal location error should be less than the error indicated by the uncertainty code with 67% confidence. + Bits 7 to 31 shall be ignored + */ + long horizontalAccuracy = 120L; + return horizontalAccuracy; + } + + @Override + protected long getVerticalAccuracy() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.8 + The Vertical-Accuracy AVP is of type Unsigned32. Bits 6-0 corresponds to Uncertainty Code defined in 3GPP TS 23.032 [3]. + The Vertical location error should be less than the error indicated by the uncertainty code with 67% confidence. + Bits 7 to 31 shall be ignored + */ + long verticalAccuracy = 3237L; + return verticalAccuracy; + } + + @Override + protected int getVerticalRequested() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.9 + VERTICAL_COORDINATE_IS_NOT REQUESTED (0) + VERTICAL_COORDINATE_IS_REQUESTED (1) + */ + int verticalRequested = 0; + return verticalRequested; + } + + @Override + protected int getResponseTime() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.11 + LOW_DELAY (0) + DELAY_TOLERANT (1) + */ + int responseTime = 1; + return responseTime; + } + + @Override + protected int getVelocityRequested() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.10 + VELOCITY_IS_NOT_REQUESTED (0) + VELOCITY_IS_REQUESTED (1) + */ + int velocityRequested = 0; + return velocityRequested; + } + + @Override + protected long getSupportedGADShapes() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.12 + The Supported-GAD-Shapes AVP is of type Unsigned32 and it shall contain a bitmask. + A node shall mark in the BIT STRING all Shapes defined in 3GPP TS 23.032 [3] it supports. + Bits 6-0 in shall indicate the supported Shapes defined in 3GPP TS 23.032 [3]. Bits 7 to 31 shall be ignored. + ellipsoidPoint (0) + ellipsoidPointWithUncertaintyCircle (1) + ellipsoidPointWithUncertaintyEllipse (2) + polygon (3) + ellipsoidPointWithAltitude (4) + ellipsoidPointWithAltitudeAndUncertaintyElipsoid (5) + ellipsoidArc (6) + */ + long supportedGADShapes = 3L; + return supportedGADShapes; + } + + @Override + protected long getLSCServiceTypeId() { + long lcsServiceTypeId = 234L; + return lcsServiceTypeId; + } + + @Override + protected String getLCSCodeword() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.1 + The LCS-Codeword AVP is of type UTF8String. + It indicates the potential codeword string to send in a notification message to the UE + */ + String lcsCodeword = "rcgl49f9f$#ERSD"; + return lcsCodeword; + } + + @Override + protected String getServiceSelection() { + String apn = "restcomm.org"; + return apn; + } + + @Override + protected int getLCSPrivacyCheckSession() { + /* + 3GPP TS 291.172 v13.0.0 section 7.4.22 + LCS-Privacy-Check-Session ::= + { LCS-Privacy-Check } + 3GPP TS 29.172 v13.0.0 section 7.4.14 + ALLOWED_WITHOUT_NOTIFICATION (0) + ALLOWED_WITH_NOTIFICATION (1) + ALLOWED_IF_NO_RESPONSE (2) + RESTRICTED_IF_NO_RESPONSE (3) + NOT_ALLOWED (4) + */ + int lcsPrivacyCheckSession = 2; + return lcsPrivacyCheckSession; + } + + @Override + protected int getLCSPrivacyCheckNonSession() { + /* + 3GPP TS 291.172 v13.0.0 section 7.4.22 + LCS-Privacy-Check-Non-Session ::= + { LCS-Privacy-Check } + 3GPP TS 29.172 v13.0.0 section 7.4.14 + ALLOWED_WITHOUT_NOTIFICATION (0) + ALLOWED_WITH_NOTIFICATION (1) + ALLOWED_IF_NO_RESPONSE (2) + RESTRICTED_IF_NO_RESPONSE (3) + NOT_ALLOWED (4) + */ + int lcsPrivacyCheckNonSession = 4; + return lcsPrivacyCheckNonSession; + } + + @Override + protected long getDeferredLocationType() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.36 + Bit Event Type Description + 0 UE-Available Any event in which the SGSN has established a contact with the UE. + 1 Entering-Into-Area An event where the UE enters a pre-defined geographical area. + 2 Leaving-From-Area An event where the UE leaves a pre-defined geographical area. + 3 Being-Inside-Area An event where the UE is currently within the pre-defined geographical area.For this event, + the value of Occurrence-Info AVP is always treated as set to “ONE_TIME_EVENT”. + 4 Periodic-LDR An event where a defined periodic timer expires in the UE and activates a location report or a location request. + */ + long deferredLocationType = 8L; + return deferredLocationType; + } + + @Override + protected byte[] getLCSReferenceNumber() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.37 + The LCS-Reference-Number AVP is of type OctetString of length 1. It shall contain the reference number identifying the deferred location request. + */ + String lcsRefNumber = "4C4353353739"; + byte[] lcsRefNum = lcsRefNumber.getBytes(); + return lcsRefNum; + } + + @Override + protected int getOccurrenceInfo() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.43 + The Occurrence-Info AVP is of type Enumerated. The following values are defined: + ONE_TIME_EVENT (0) + MULTIPLE_TIME_EVENT (1) + */ + int occurrenceInfo = 1; + return occurrenceInfo; + } + + @Override + protected long getIntervalTime() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.44 + The Interval-Time AVP is of type Unsigned32 and it contains minimum time interval between area reports, in seconds. + */ + long intervalTime = 3600L; + return intervalTime; + } + + @Override + protected long getAreaType() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.41 + "Country Code" 0 + "PLMN ID" 1 + "Location Area ID" 2 + "Routing Area ID" 3 + "Cell Global ID" 4 + "UTRAN Cell ID" 5 + */ + long areaType = 3L; + return areaType; + } + + @Override + protected byte[] getAreaIdentification() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.42 + The Area-Identification AVP is of type OctetString and shall contain the identification of the area applicable + for the change of area event based deferred location reporting. Octets are coded as described in 3GPP TS 29.002 [24]. + */ + String areaId = "617265613531"; + byte[] areaIdentification = areaId.getBytes(); + return areaIdentification; + } + + @Override + protected java.net.InetAddress getGMLCAddress() { + + try { + java.net.InetAddress gmlcAddress = java.net.InetAddress.getLocalHost(); + return gmlcAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected long getPLRFLags() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.52 + Bit Event Type Description + 0 MO-LR-ShortCircuit-Indicator This bit, when set, indicates that the MO-LR short circuit feature is requested + for the periodic location.This bit is applicable only when the deferred MT-LR procedure is + initiated for a periodic location event and when the message is sent over Lgd interface. + 1 Optimized-LCS-Proc-Req This bit, when set, indicates that the GMLC is requesting the optimized LCS procedure + for the combined MME/SGSN. This bit is applicable only when the MT-LR procedure is + initiated by the GMLC. The GMLC shall set this bit only when the HSS indicates the combined MME/SGSN + node supporting the optimized LCS procedure. + 2 Delayed-Location-Reporting-Support-Indicator This bit, when set, indicates that the GMLC supports delayed location reporting for UEs transiently + not reachable (e.g. UEs in extended idle mode DRX or Power Saving Mode) as specified in subclauses + 9.1.6 and 9.1.15 of 3GPP TS 23.271 [2], i.e. that the GMLC supports receiving a + PROVIDE SUBSCRIBER LOCATION RESPONSE with the UE-Transiently-Not-Reachable-Indicator set in the + PLA-Flags IE; and receiving the location information in a subsequent SUBSCRIBER LOCATION REPORT + when the UE becomes reachable. + */ + long plrFlags = 4L; + return plrFlags; + } + + @Override + protected long getReportingAmount() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.46 + The Reporting-Amount AVP is of type Unsigned32 and it contains reporting frequency. Its minimum value shall be 1 and maximum value shall be 8639999. + */ + long reportingAmount = 8639910L; + return reportingAmount; + } + + @Override + protected long getReportingInterval() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.47 + The Interval-Time AVP is of type Unsigned32 and it contains reporting frequency. Its minimum value shall be 1 and maximum value shall be 8639999. + */ + long reportingInterval = 8639998L; + return reportingInterval; + } + + @Override + protected int getPrioritizedListIndicator() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.51 + The Prioritized-List-Indicator AVP is of type Enumerated and it indicates if the PLMN-ID-List is provided in prioritized order or not. + NOT_PRIORITIZED (0) + PRIORITIZED (1) + */ + int prioritizedListIndicator = 0; + return prioritizedListIndicator; + } + + @Override + protected byte[] getVisitedPLMNId() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.49 + The PLMN-ID-List AVP is of type Grouped. + AVP format: + PLMN-ID-List ::= + { Visited-PLMN-Id } + [ Periodic-Location-Support-Indicator ] + *[ AVP ] + If not included, the default value of Periodic-Location-Support-Indicator shall be considered as "NOT_SUPPORTED" (0). + */ + byte[] visitedPlmnIdList = hexStringToByteArray("473800"); + return visitedPlmnIdList; + } + + @Override + protected int getPeriodicLocationSupportIndicator() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.50 + The Periodic-Location-Support-Indicator AVP is of type Enumerated and it indicates if the given PLMN-ID (indicated by Visited-PLMN-Id) + supports periodic location or not. + NOT_SUPPORTED (0) + SUPPORTED (1) + */ + int periodicLocationSupportIndicator = 1; + return periodicLocationSupportIndicator; + } + + public boolean isReceivedPLA() { + return receivedPLA; + } + + public boolean isSentPLR() { + return sentPLR; + } + +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/SLgSessionBasicDefFlowTest.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/SLgSessionBasicDefFlowTest.java new file mode 100644 index 000000000..4fc357fbc --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/SLgSessionBasicDefFlowTest.java @@ -0,0 +1,224 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.stack.functional.slg.base; + +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.jdiameter.api.DisconnectCause; +import org.jdiameter.api.Mode; +import org.jdiameter.api.Peer; +import org.jdiameter.api.PeerState; +import org.jdiameter.api.PeerTable; +import org.jdiameter.api.Stack; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * + * @author Fernando Mendioroz + * @author Alexandre Mendonca + * @author Bartosz Baranowski + */ +@RunWith(Parameterized.class) +public class SLgSessionBasicDefFlowTest { + // TODO: add test on replicated nodes ? + private ClientLRR clientNode; + private ServerLRA serverNode1; + private URI clientConfigURI; + private URI serverNode1ConfigURI; + + /** + * @param clientConfigUrl + * // @param node1 + * // @param node2 + * @param serverNode1ConfigURL + */ + + public SLgSessionBasicDefFlowTest(String clientConfigUrl, String serverNode1ConfigURL) throws Exception { + super(); + this.clientConfigURI = new URI(clientConfigUrl); + this.serverNode1ConfigURI = new URI(serverNode1ConfigURL); + } + + @Before + public void setUp() throws Exception { + try { + this.clientNode = new ClientLRR(); + this.serverNode1 = new ServerLRA(); + + this.serverNode1.init(new FileInputStream(new File(this.serverNode1ConfigURI)), "SERVER1"); + this.serverNode1.start(); + + this.clientNode.init(new FileInputStream(new File(this.clientConfigURI)), "CLIENT"); + this.clientNode.start(Mode.ANY_PEER, 10, TimeUnit.SECONDS); + Stack stack = this.clientNode.getStack(); + List peers = stack.unwrap(PeerTable.class).getPeerTable(); + if (peers.size() == 1) { + // ok + } + else if (peers.size() > 1) { + // works better with replicated, since disconnected peers are also listed + boolean foundConnected = false; + for (Peer p : peers) { + if (p.getState(PeerState.class).equals(PeerState.OKAY)) { + if (foundConnected) { + throw new Exception("Wrong number of connected peers: " + peers); + } + foundConnected = true; + } + } + } + else { + throw new Exception("Wrong number of connected peers: " + peers); + } + } + catch (Throwable e) { + e.printStackTrace(); + } + } + + @After + public void tearDown() { + if (this.serverNode1 != null) { + try { + this.serverNode1.stop(DisconnectCause.REBOOTING); + } + catch (Exception e) { + + } + this.serverNode1 = null; + } + + if (this.clientNode != null) { + try { + this.clientNode.stop(DisconnectCause.REBOOTING); + } + catch (Exception e) { + + } + this.clientNode = null; + } + } + + @Test + public void testLocationReportBasicFlow() throws Exception { + try { + // pain of parameter tests :) ? + clientNode.sendLocationReportRequest(); + waitForMessage(); + + serverNode1.sendLocationReportAnswer(); + waitForMessage(); + } + catch (Exception e) { + e.printStackTrace(); + fail(e.toString()); + } + + if (!serverNode1.isReceivedLRR()) { + StringBuilder sb = new StringBuilder("Did not receive LRR! "); + sb.append("Server ER:\n").append(serverNode1.createErrorReport(this.serverNode1.getErrors())); + + fail(sb.toString()); + } + if (!clientNode.isReceivedLRA()) { + StringBuilder sb = new StringBuilder("Did not receive LRA! "); + sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); + + fail(sb.toString()); + } + + if (!clientNode.isPassed()) { + StringBuilder sb = new StringBuilder(); + sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); + + fail(sb.toString()); + } + + if (!serverNode1.isPassed()) { + StringBuilder sb = new StringBuilder(); + sb.append("Server ER:\n").append(serverNode1.createErrorReport(this.serverNode1.getErrors())); + + fail(sb.toString()); + } + } + + @Parameters + public static Collection data() { + + String client = "configurations/functional-slg/config-client.xml"; + String server1 = "configurations/functional-slg/config-server-node1.xml"; + + //String replicatedClient = "configurations/functional-slh/replicated-config-client.xml"; + //String replicatedServer1 = "configurations/functional-slh/replicated-config-server-node1.xml"; + + Class t = SLgSessionBasicDefFlowTest.class; + client = t.getClassLoader().getResource(client).toString(); + server1 = t.getClassLoader().getResource(server1).toString(); + //replicatedClient = t.getClassLoader().getResource(replicatedClient).toString(); + //replicatedServer1 = t.getClassLoader().getResource(replicatedServer1).toString(); + + return Arrays.asList(new Object[][] { { client, server1 }/*, { replicatedClient, replicatedServer1 } */}); + } + + private void waitForMessage() { + try { + Thread.sleep(2000); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/SLgSessionBasicImmFlowTest.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/SLgSessionBasicImmFlowTest.java new file mode 100644 index 000000000..66da7254d --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/SLgSessionBasicImmFlowTest.java @@ -0,0 +1,225 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg.base; + +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.jdiameter.api.DisconnectCause; +import org.jdiameter.api.Mode; +import org.jdiameter.api.Peer; +import org.jdiameter.api.PeerState; +import org.jdiameter.api.PeerTable; +import org.jdiameter.api.Stack; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * + * @author Fernando Mendioroz + * @author Alexandre Mendonca + * @author Bartosz Baranowski + */ +@RunWith(Parameterized.class) +public class SLgSessionBasicImmFlowTest { + // TODO: add test on replicated nodes ? + private ClientPLR clientNode; + private ServerPLA serverNode1; + private URI clientConfigURI; + private URI serverNode1ConfigURI; + + /** + * @param clientConfigUrl + * @param serverNode1ConfigURL + * // @param node2 + * // @param serverCount + */ + public SLgSessionBasicImmFlowTest(String clientConfigUrl, String serverNode1ConfigURL) throws Exception { + super(); + this.clientConfigURI = new URI(clientConfigUrl); + this.serverNode1ConfigURI = new URI(serverNode1ConfigURL); + } + + @Before + public void setUp() throws Exception { + try { + this.clientNode = new ClientPLR(); + this.serverNode1 = new ServerPLA(); + + this.serverNode1.init(new FileInputStream(new File(this.serverNode1ConfigURI)), "SERVER1"); + this.serverNode1.start(); + + this.clientNode.init(new FileInputStream(new File(this.clientConfigURI)), "CLIENT"); + this.clientNode.start(Mode.ANY_PEER, 10, TimeUnit.SECONDS); + Stack stack = this.clientNode.getStack(); + List peers = stack.unwrap(PeerTable.class).getPeerTable(); + if (peers.size() == 1) { + // ok + } + else if (peers.size() > 1) { + // works better with replicated, since disconnected peers are also listed + boolean foundConnected = false; + for (Peer p : peers) { + if (p.getState(PeerState.class).equals(PeerState.OKAY)) { + if (foundConnected) { + throw new Exception("Wrong number of connected peers: " + peers); + } + foundConnected = true; + } + } + } + else { + throw new Exception("Wrong number of connected peers: " + peers); + } + } + catch (Throwable e) { + e.printStackTrace(); + } + } + + @After + public void tearDown() { + if (this.serverNode1 != null) { + try { + this.serverNode1.stop(DisconnectCause.REBOOTING); + } + catch (Exception e) { + + } + this.serverNode1 = null; + } + + if (this.clientNode != null) { + try { + this.clientNode.stop(DisconnectCause.REBOOTING); + } + catch (Exception e) { + + } + this.clientNode = null; + } + } + + @Test + public void testProvideLocationRequestBasicFlow() throws Exception { + try { + // pain of parameter tests :) ? + clientNode.sendProvideLocationRequest(); + waitForMessage(); + + serverNode1.sendProvideLocationAnswer(); + waitForMessage(); + + } + catch (Exception e) { + e.printStackTrace(); + fail(e.toString()); + } + + if (!serverNode1.isReceivedPLR()) { + StringBuilder sb = new StringBuilder("Did not receive PLR! "); + sb.append("Server ER:\n").append(serverNode1.createErrorReport(this.serverNode1.getErrors())); + + fail(sb.toString()); + } + if (!clientNode.isReceivedPLA()) { + StringBuilder sb = new StringBuilder("Did not receive PLA! "); + sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); + + fail(sb.toString()); + } + + if (!clientNode.isPassed()) { + StringBuilder sb = new StringBuilder(); + sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); + + fail(sb.toString()); + } + + if (!serverNode1.isPassed()) { + StringBuilder sb = new StringBuilder(); + sb.append("Server ER:\n").append(serverNode1.createErrorReport(this.serverNode1.getErrors())); + + fail(sb.toString()); + } + } + + @Parameters + public static Collection data() { + + String client = "configurations/functional-slg/config-client.xml"; + String server1 = "configurations/functional-slg/config-server-node1.xml"; + + //String replicatedClient = "configurations/functional-slh/replicated-config-client.xml"; + //String replicatedServer1 = "configurations/functional-slh/replicated-config-server-node1.xml"; + + Class t = SLgSessionBasicImmFlowTest.class; + client = t.getClassLoader().getResource(client).toString(); + server1 = t.getClassLoader().getResource(server1).toString(); + //replicatedClient = t.getClassLoader().getResource(replicatedClient).toString(); + //replicatedServer1 = t.getClassLoader().getResource(replicatedServer1).toString(); + + return Arrays.asList(new Object[][] { { client, server1 }/*, { replicatedClient, replicatedServer1 } */}); + } + + private void waitForMessage() { + try { + Thread.sleep(2000); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ServerLRA.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ServerLRA.java new file mode 100644 index 000000000..5f7c8a639 --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ServerLRA.java @@ -0,0 +1,227 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg.base; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.LocationReportAnswer; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.mobicents.diameter.stack.functional.Utils; +import org.mobicents.diameter.stack.functional.slg.AbstractDeferredServer; + +import static sun.jdbc.odbc.JdbcOdbcObject.hexStringToByteArray; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ServerLRA extends AbstractDeferredServer { + + protected boolean receivedLRR; + protected boolean sentLRA; + protected boolean receivedPLR; + + protected LocationReportRequest locationReportRequest; + protected ProvideLocationRequest provideLocationRequest; + + public void sendLocationReportAnswer() throws Exception { + if (!receivedLRR || locationReportRequest == null) { + fail("Did not receive LRR or answer already sent.", null); + throw new Exception("Did not receive LRR or answer already sent. Request: " + this.locationReportRequest); + } + + LocationReportAnswer lra = super.createLRA(locationReportRequest, 2001); + + super.serverSLgSession.sendLocationReportAnswer(lra); + + this.sentLRA = true; + locationReportRequest = null; + Utils.printMessage(log, super.stack.getDictionary(), lra.getMessage(), true); + } + + /* (non-Javadoc) + * @see org.mobicents.diameter.stack.functional.TBase#processRequest(org.jdiameter.api.Request) + */ + @Override + public Answer processRequest(Request request) { + int code = request.getCommandCode(); + if (code != LocationReportRequest.code) { + fail("Received Request with code not used by SLg!. Code[" + request.getCommandCode() + "]", null); + return null; + } + if (super.serverSLgSession != null) { + // do fail? + fail("Received Request in base listener, not in app specific!" + code, null); + } else { + try { + + super.serverSLgSession = this.sessionFactory.getNewAppSession(request.getSessionId(), getApplicationId(), ServerSLgSession.class, (Object) null); + ((NetworkReqListener) this.serverSLgSession).processRequest(request); + + } catch (Exception e) { + e.printStackTrace(); + fail(null, e); + } + } + return null; + } + + @Override + public void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + if (this.receivedLRR) { + fail("Received LRR more than once", null); + return; + } + this.receivedLRR = true; + this.locationReportRequest = request; + } + + @Override + public void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + if (this.receivedPLR) { + fail("Received PLR more than once", null); + return; + } + this.receivedPLR = true; + this.provideLocationRequest = request; + } + + @Override + protected java.net.InetAddress getGMLCAddress() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.7 + The GMLC-Address AVP is of type Address and shall contain the IPv4 or IPv6 address of H-GMLC or the V-GMLC associated with the serving node. + */ + try { + java.net.InetAddress gmlcAddress = java.net.InetAddress.getLocalHost(); + return gmlcAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected long getLRAFLags() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.56 + Bit Event Type Description + 0 MO-LR-ShortCircuit-Indicator This bit, when set, indicates that the MO-LR short circuit feature is used for obtaining location estimate. + This bit is applicable only when the message is sent over Lgd interface. + */ + long lraFlags = 0; + return lraFlags; + } + + @Override + protected int getPrioritizedListIndicator() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.51 + The Prioritized-List-Indicator AVP is of type Enumerated and it indicates if the PLMN-ID-List is provided in prioritized order or not. + NOT_PRIORITIZED (0) + PRIORITIZED (1) + */ + int prioritizedListIndicator = 0; + return prioritizedListIndicator; + } + + @Override + protected byte[] getVisitedPLMNId() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.49 + The PLMN-ID-List AVP is of type Grouped. + AVP format: + PLMN-ID-List ::= + { Visited-PLMN-Id } + [ Periodic-Location-Support-Indicator ] + *[ AVP ] + If not included, the default value of Periodic-Location-Support-Indicator shall be considered as "NOT_SUPPORTED" (0). + */ + byte[] visitedPlmnIdList = hexStringToByteArray("471800"); + return visitedPlmnIdList; + } + + @Override + protected int getPeriodicLocationSupportIndicator() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.50 + The Periodic-Location-Support-Indicator AVP is of type Enumerated and it indicates if the given PLMN-ID (indicated by Visited-PLMN-Id) + supports periodic location or not. + NOT_SUPPORTED (0) + SUPPORTED (1) + */ + int periodicLocationSupportIndicator = 1; + return periodicLocationSupportIndicator; + } + + @Override + protected byte[] getLCSReferenceNumber() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.37 + The LCS-Reference-Number AVP is of type OctetString of length 1. It shall contain the reference number identifying the deferred location request. + */ + String lcsRefNumber = "4C4353353739"; + byte[] lcsRefNum = lcsRefNumber.getBytes(); + return lcsRefNum; + } + + public boolean isReceivedLRR() { + return receivedLRR; + } + + public boolean isSentLRA() { + return sentLRA; + } + +} + diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ServerPLA.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ServerPLA.java new file mode 100644 index 000000000..1474286ad --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slg/base/ServerPLA.java @@ -0,0 +1,410 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slg.base; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.api.slg.events.LocationReportRequest; +import org.jdiameter.api.slg.events.ProvideLocationRequest; +import org.jdiameter.api.slg.events.ProvideLocationAnswer; +import org.mobicents.diameter.stack.functional.Utils; +import org.mobicents.diameter.stack.functional.slg.AbstractImmediateServer; + +/** + * + * @author Fernando Mendioroz + * + */ +public class ServerPLA extends AbstractImmediateServer { + + protected boolean receivedPLR; + protected boolean sentPLA; + protected boolean receivedLRR; + + protected ProvideLocationRequest provideLocationRequest; + protected LocationReportRequest locationReportRequest; + + public void sendProvideLocationAnswer() throws Exception { + if (!receivedPLR || provideLocationRequest == null) { + fail("Did not receive PLR or answer already sent.", null); + throw new Exception("Did not receive PLR or answer already sent. Request: " + this.provideLocationRequest); + } + + ProvideLocationAnswer pla = super.createPLA(provideLocationRequest, 2001); + + super.serverSLgSession.sendProvideLocationAnswer(pla); + + this.sentPLA = true; + provideLocationRequest = null; + Utils.printMessage(log, super.stack.getDictionary(), pla.getMessage(), true); + } + + + /* (non-Javadoc) + * @see org.mobicents.diameter.stack.functional.TBase#processRequest(org.jdiameter.api.Request) + */ + @Override + public Answer processRequest(Request request) { + int code = request.getCommandCode(); + if (code != ProvideLocationRequest.code) { + fail("Received Request with code not used by SLg!. Code[" + request.getCommandCode() + "]", null); + return null; + } + if (super.serverSLgSession != null) { + // do fail? + fail("Received Request in base listener, not in app specific!" + code, null); + } else { + try { + + super.serverSLgSession = this.sessionFactory.getNewAppSession(request.getSessionId(), getApplicationId(), ServerSLgSession.class, (Object) null); + ((NetworkReqListener) this.serverSLgSession).processRequest(request); + + } catch (Exception e) { + e.printStackTrace(); + fail(null, e); + } + } + return null; + } + + @Override + public void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + if (this.receivedPLR) { + fail("Received PLR more than once", null); + return; + } + this.receivedPLR = true; + this.provideLocationRequest = request; + } + + @Override + public void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + if (this.receivedLRR) { + fail("Received LRR more than once", null); + return; + } + this.receivedLRR = true; + this.locationReportRequest = request; + } + + @Override + protected byte[] getLocationEstimate() { + String locEstimate = "S35°38'15.37\" WE109°45'21.77\""; + byte[] locationEstimate = locEstimate.getBytes(); + return locationEstimate; + } + + @Override + protected int getAccuracyFulfilmentIndicator() { +/* + 3GPP TS 29.172 v13.0.0 section 7.4.15 + REQUESTED_ACCURACY_FULFILLED (0) + REQUESTED_ACCURACY_NOT_FULFILLED (1) +*/ + int accuracyFulfilmentIndicator = 0; + return accuracyFulfilmentIndicator; + } + + @Override + protected long getAgeOfLocationEstimate() { +/* + 3GPP TS 29.172 v13.0.0 section 7.4.19 + The Age-Of-Location-Estimate AVP is of type Unsigned32. + It indicates how long ago the location estimate was obtained in minutes, as indicated in 3GPP TS 29.002 [19]. +*/ + long ageOfLocationEstimate = 37L; + return ageOfLocationEstimate; + } + + @Override + protected byte[] getVelocityEstimate() { +/* + 3GPP TS 29.172 v13.0.0 section 7.4.17 + The Velocity-Estimate AVP is of type OctetString. + It is composed of 4 or more octets with an internal structure according to 3GPP TS 23.032 [3]. +*/ + String vel = "210"; + byte[] velocityEstimate = vel.getBytes(); + return velocityEstimate; + } + + @Override + protected byte[] getEUTRANPositioningData() { +/* + 3GPP TS 29.172 v13.0.0 section 7.4.18 + The EUTRAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "Positioning-Data" Information Element as defined in 3GPP TS 29.171 [7]. +*/ + String eutran = "654E423435336C7465613233"; + byte[] eutranPositioningData = eutran.getBytes(); + return eutranPositioningData; + } + + @Override + protected byte[] getECGI() { +/* + 3GPP TS 29.172 v13.0.0 section 7.4.19 + The ECGI AVP is of type OctetString. It indicates the E-UTRAN Cell Global Identifier. + It is coded according to clause 8.21.5, in 3GPP TS 29.274 [8]. +*/ + String eCgi = "654E4239343337"; + byte[] ecgi = eCgi.getBytes(); + return ecgi; + } + + @Override + protected byte[] getGERANPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.30 + The GERAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "Positioning Data" Information Element as defined in 3GPP TS 49.031 [20] + */ + String geran = "42545339343342534333"; + byte[] geranPositioningData = geran.getBytes(); + return geranPositioningData; + } + + @Override + protected byte[] getGERANGANSSPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.30 + The GERAN-GANSS-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "GANSS Positioning Data" Information Element as defined in 3GPP TS 49.031 [20] + */ + String geranGanss = "4254533733524E4331473433"; + byte[] geranGanssPositioningData = geranGanss.getBytes(); + return geranGanssPositioningData; + } + + @Override + protected byte[] getCellGlobalIdentity() { + String cgi = "A342784713907"; + byte[] CellGlobalIdentity = cgi.getBytes(); + return CellGlobalIdentity; + } + + @Override + protected byte[] getUTRANPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.33 + The UTRAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "positioningDataDiscriminator" and the "positioningDataSet" included in the + "positionData" Information Element as defined in 3GPP TS 25.413 [21]. + */ + String utran = "4E42393433524E4331"; + byte[] utranPositioningData = utran.getBytes(); + return utranPositioningData; + } + + @Override + protected byte[] getUTRANGANSSPositioningData() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.33 + The UTRAN-Positioning-Data AVP is of type OctetString. + It shall contain the encoded content of the "positioningDataDiscriminator" and the "positioningDataSet" included in the + "positionData" Information Element as defined in 3GPP TS 25.413 [21]. + */ + String utranGanss = "4E42303331524E4335473433"; + byte[] utranGanssPositioningData = utranGanss.getBytes(); + return utranGanssPositioningData; + } + + @Override + protected byte[] getServiceAreaIdentity() { + /* + 3GPP TS 29.172 v13.0.0 -> 3GPP TS 29.272 + SAI shall contain the current service area of the target UE. The Service Area Identifier (SAI) is used to globally identify a service area. + This Information Element is applicable only when the UE is attached to UTRAN access and when the message is sent by the SGSN or combined MME/SGSN + */ + String sai = "736572766963652D617265612D756D74732D33"; + byte[] serviceAreaIdentity = sai.getBytes(); + return serviceAreaIdentity; + } + + @Override + protected byte[] getSGSNNumber() { + String sgsnNumString = "59899004501"; + byte[] sgsnNumber = sgsnNumString.getBytes(); + return sgsnNumber; + } + + @Override + protected String getSGSNName() { + String sgsnName = "SGSN01"; + return sgsnName; + } + + @Override + protected String getSGSNRealm() { + String sgsnRealm = "sgsn.restcomm.com"; + return sgsnRealm; + } + + @Override + protected String getMMEName() { + String mmeName = "MME710"; + return mmeName; + } + + @Override + protected String getMMERealm() { + String mmeRealm = "mme.restcomm.com"; + return mmeRealm; + } + + @Override + protected byte[] getMSCNumber() { + String mscNumString = "59899001207"; + byte[] mscNumber = mscNumString.getBytes(); + return mscNumber; + } + + @Override + protected String get3GPPAAAServerName() { + String tgppAAAServerName = "aaa.restcomm.com"; + return tgppAAAServerName; + } + + @Override + protected long getLCSCapabilitiesSets() { + long lcsCapabilitiesSets = 99900123L; + return lcsCapabilitiesSets; + } + + @Override + protected java.net.InetAddress getGMLCAddress() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.7 + The GMLC-Address AVP is of type Address and shall contain the IPv4 or IPv6 address of H-GMLC or the V-GMLC associated with the serving node. + */ + try { + java.net.InetAddress gmlcAddress = java.net.InetAddress.getLocalHost(); + return gmlcAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected long getPLAFLags() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.53 + Bit Event Type Description + 0 Deferred-MT-LR-Response-Indicator This bit, when set, indicates that the message is sent in response to the deferred-MT location request. + This bit is applicable only when the message is sent over Lgd interface. + 1 MO-LR-ShortCircuit-Indicator This bit, when set, indicates that the MO-LR short circuit feature is accepted by the UE, + for periodic location reporting. This bit is applicable only when the message is sent over Lgd interface. + 2 Optimized-LCS-Proc-Performed This bit, when set, indicates that the combined MME/SGSN has performed the optimized LCS procedure + to retrieve the location of the target UE. This bit is applicable only when the message is sent for + the MT-LR procedure. + 3 UE-Transiently-Not-Reachable-Indicator This bit, when set, indicates that the UE is transiently not reachable due to power saving + (e.g. UE is in extended idle mode DRX or in Power Saving Mode), and that the location information + will be returned in a subsequent Subscriber Location Report when the UE becomes reachable. + */ + long plaFlags = 8L; + return plaFlags; + } + + @Override + protected long getCellPortionId() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.58 + The Cell-Portion-ID AVP is of type Unsigned32. It indicates the current Cell Portion location of the target UE as provided by the E-SMLC. + It shall contain the value of the "Cell Portion ID" Information Element as defined in 3GPP TS 29.171 + */ + long cellPortionId = 34923L; + return cellPortionId; + } + + @Override + protected String getCivicAddress() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.61 + The Civic-Address AVP is of type UTF8String. + It contains the XML document carried in the "Civic Address" Information Element as defined in 3GPP TS 29.171. + */ + String civicAddress = "\n" + + " US\n" + + " CA\n" + + " Sacramento\n" + + " Colorado\n" + + " 223\n" + + " Boulevard\n" + + " A\n" + + " "; // From IETF RFC 6848, XML Example with Street Type Prefix and House Number Prefix + return civicAddress; + } + + @Override + protected long getBarometricPressure() { + /* + 3GPP TS 29.172 v13.0.0 section 7.4.62 + The Barometric-Pressure AVP is of type Unsigned32. + It contains the "Barometric Pressure" Information Element as defined in 3GPP TS 29.171. + */ + long barometricPressure = 101327L; + return barometricPressure; + } + + public boolean isReceivedPLR() { + return receivedPLR; + } + + public boolean isSentPLA() { + return sentPLA; + } + + + +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/AbstractClient.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/AbstractClient.java new file mode 100644 index 000000000..e50af1ad5 --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/AbstractClient.java @@ -0,0 +1,213 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slh; + +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpSet; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.Mode; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ClientSLhSessionListener; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.slh.LCSRoutingInfoRequestImpl; +import org.jdiameter.common.impl.app.slh.SLhSessionFactoryImpl; +import org.mobicents.diameter.stack.functional.TBase; + +/** + * + * @author Fernando Mendioroz + * + */ +public abstract class AbstractClient extends TBase implements ClientSLhSessionListener { + + // NOTE: implementing NetworkReqListener since its required for stack to + // know we support it... ech. + + protected ClientSLhSession clientSLhSession; + + public void init(InputStream configStream, String clientID) throws Exception { + try { + super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777291)); + SLhSessionFactoryImpl slhSessionFactory = new SLhSessionFactoryImpl(this.sessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLhSession.class, slhSessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLhSession.class, slhSessionFactory); + + slhSessionFactory.setClientSessionListener(this); + + this.clientSLhSession = ((ISessionFactory) this.sessionFactory).getNewAppSession(this.sessionFactory.getSessionId("xx-SLh-TESTxx"), getApplicationId(), + ClientSLhSession.class, null); + } + finally { + try { + configStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + // ----------- delegate methods so + + public void start() throws IllegalDiameterStateException, InternalException { + stack.start(); + } + + public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException { + stack.start(mode, timeOut, timeUnit); + } + + public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException { + stack.stop(timeOut, timeUnit, disconnectCause); + } + + public void stop(int disconnectCause) { + stack.stop(disconnectCause); + } + + // ------- def methods, to fail :) + + public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, + RouteException, OverloadException { + fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doLCSRoutingInfoAnswerEvent(ClientSLhSession session, LCSRoutingInfoRequest request, LCSRoutingInfoAnswer answer) throws InternalException, + IllegalDiameterStateException, RouteException, OverloadException { + fail("Received \"RIA\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + // ----------- conf + + public String getSessionId() { + return this.clientSLhSession.getSessionId(); + } + + public ClientSLhSession getSession() { + return this.clientSLhSession; + } + + protected abstract String getUserName(); + protected abstract byte[] getMSISDN(); + protected abstract byte[] getGMLCNumber(); + + // ----------- 3GPP TS 29.173 reference + + protected LCSRoutingInfoRequest createRIR(ClientSLhSession slhSession) throws Exception { + /* + < LCS-Routing-Info-Request> ::= < Diameter Header: 8388622, REQ, PXY, 16777291 > + + < Session-Id > + [ Vendor-Specific-Application-Id ] + { Auth-Session-State } + { Origin-Host } + { Origin-Realm } + [ Destination-Host ] + { Destination-Realm } + [ User-Name ] + [ MSISDN ] + [ GMLC-Number ] + *[ Supported-Features ] + *[ Proxy-Info ] + *[ Route-Record ] + *[ AVP ] + + */ + // Create LCSRoutingInfoRequest + LCSRoutingInfoRequest rir = new LCSRoutingInfoRequestImpl(slhSession.getSessions().get(0).createRequest(LCSRoutingInfoRequest.code, getApplicationId(), + getServerRealmName())); + // < LCS-Routing-Info-Request> ::= < Diameter Header: 8388622, REQ, PXY, 16777291 > + + AvpSet reqSet = rir.getMessage().getAvps(); + + if (reqSet.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) { + AvpSet vendorSpecificApplicationId = reqSet.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false); + // 1* [ Vendor-Id ] + vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true); + // 0*1{ Auth-Application-Id } + vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true); + } + + // { Auth-Session-State } + if (reqSet.getAvp(Avp.AUTH_SESSION_STATE) == null) { + reqSet.addAvp(Avp.AUTH_SESSION_STATE, 1); + } + + // { Origin-Host } + reqSet.removeAvp(Avp.ORIGIN_HOST); + reqSet.addAvp(Avp.ORIGIN_HOST, getClientURI(), true); + + // [ User-Name ] + String userName = getUserName(); + if (userName != null) { + reqSet.addAvp(Avp.USER_NAME, userName, 10415, true, false, false); + } + + // [ MSISDN ] + byte[] msisdn = getMSISDN(); + if (msisdn != null){ + reqSet.addAvp(Avp.MSISDN, msisdn, 10415, true, false); + } + + // [ GMLC-Number ] + byte[] gmlcNumber = getGMLCNumber(); + if (gmlcNumber != null){ + reqSet.addAvp(Avp.GMLC_NUMBER, gmlcNumber, 10415, false, false); + } + + return rir; + } + +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/AbstractServer.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/AbstractServer.java new file mode 100644 index 000000000..9289eb1f5 --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/AbstractServer.java @@ -0,0 +1,356 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.mobicents.diameter.stack.functional.slh; + +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +import org.jdiameter.api.ApplicationId; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpSet; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.Mode; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.app.AppAnswerEvent; +import org.jdiameter.api.app.AppRequestEvent; +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.api.slh.ServerSLhSessionListener; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.impl.app.slh.LCSRoutingInfoAnswerImpl; +import org.jdiameter.common.impl.app.slh.SLhSessionFactoryImpl; +import org.mobicents.diameter.stack.functional.TBase; + +/** + * + * @author Fernando Mendioroz + * + */ +public abstract class AbstractServer extends TBase implements ServerSLhSessionListener { + + // NOTE: implementing NetworkReqListener since its required for stack to + // know we support it... ech. + + protected ServerSLhSession serverSLhSession; + + public void init(InputStream configStream, String clientID) throws Exception { + try { + super.init(configStream, clientID, ApplicationId.createByAuthAppId(10415, 16777291)); + SLhSessionFactoryImpl slhSessionFactory = new SLhSessionFactoryImpl(this.sessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLhSession.class, slhSessionFactory); + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLhSession.class, slhSessionFactory); + slhSessionFactory.setServerSessionListener(this); + } + finally { + try { + configStream.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + } + + // ----------- delegate methods so + + public void start() throws IllegalDiameterStateException, InternalException { + stack.start(); + } + + public void start(Mode mode, long timeOut, TimeUnit timeUnit) throws IllegalDiameterStateException, InternalException { + stack.start(mode, timeOut, timeUnit); + } + + public void stop(long timeOut, TimeUnit timeUnit, int disconnectCause) throws IllegalDiameterStateException, InternalException { + stack.stop(timeOut, timeUnit, disconnectCause); + } + + public void stop(int disconnectCause) { + stack.stop(disconnectCause); + } + + public void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) throws InternalException, IllegalDiameterStateException, + RouteException, OverloadException { + fail("Received \"Other\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null); + } + + public void doLCSRoutingInfoRequestEvent(ServerSLhSession session, LCSRoutingInfoRequest request) throws InternalException, IllegalDiameterStateException, + RouteException, OverloadException { + fail("Received \"RIR\" event, request[" + request + "], on session[" + session + "]", null); + } + + // -------- conf + + public String getSessionId() { + return this.serverSLhSession.getSessionId(); + } + + public void fetchSession(String sessionId) throws InternalException { + this.serverSLhSession = stack.getSession(sessionId, ServerSLhSession.class); + } + + public ServerSLhSession getSession() { + return this.serverSLhSession; + } + + protected abstract String getUserName(); + protected abstract byte[] getMSISDN(); + protected abstract byte[] getLMSI(); + protected abstract byte[] getSGSNNumber(); + protected abstract String getSGSNName(); + protected abstract String getSGSNRealm(); + protected abstract String getMMEName(); + protected abstract String getMMERealm(); + protected abstract byte[] getMSCNumber(); + protected abstract String get3GPPAAAServerName(); + protected abstract long getLCSCapabilitiesSets(); + protected abstract java.net.InetAddress getGMLCAddress(); + protected abstract byte[] getAdditionalSGSNNumber(); + protected abstract String getAdditionalSGSNName(); + protected abstract String getAdditionalSGSNRealm(); + protected abstract String getAdditionalMMEName(); + protected abstract String getAdditionalMMERealm(); + protected abstract byte[] getAdditionalMSCNumber(); + protected abstract String getAdditional3GPPAAAServerName(); + protected abstract long getAdditionalLCSCapabilitiesSets(); + protected abstract java.net.InetAddress getAdditionalGMLCAddress(); + protected abstract java.net.InetAddress getPPRAddress(); + protected abstract long getRIAFLags(); + + // ----------- 3GPP TS 29.173 reference + + public LCSRoutingInfoAnswer createRIA(LCSRoutingInfoRequest rir, long resultCode) throws Exception { + +/* + < LCS-Routing-Info-Answer> ::= < Diameter Header: 8388622, PXY, 16777291 > + + < Session-Id > + [ Vendor-Specific-Application-Id ] + [ Result-Code ] + [ Experimental-Result ] + { Auth-Session-State } + { Origin-Host } + { Origin-Realm } + *[ Supported-Features ] + [ User-Name ] + [ MSISDN ] + [ LMSI ] + [ Serving-Node ] + *[ Additional-Serving-Node ] + [ GMLC-Address ] + [ PPR-Address ] + [ RIA-Flags ] + *[ AVP ] + *[ Failed-AVP ] + *[ Proxy-Info ] + *[ Route-Record ] + + */ + LCSRoutingInfoAnswer ria = new LCSRoutingInfoAnswerImpl((Request) rir.getMessage(), resultCode); + + AvpSet reqSet = rir.getMessage().getAvps(); + AvpSet set = ria.getMessage().getAvps(); + set.removeAvp(Avp.DESTINATION_HOST); + set.removeAvp(Avp.DESTINATION_REALM); + set.addAvp(reqSet.getAvp(Avp.AUTH_APPLICATION_ID)); + + // { Vendor-Specific-Application-Id } + if (set.getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) { + AvpSet vendorSpecificApplicationId = set.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, 0, false, false); + // 1* [ Vendor-Id ] + vendorSpecificApplicationId.addAvp(Avp.VENDOR_ID, getApplicationId().getVendorId(), true); + // 0*1{ Auth-Application-Id } + vendorSpecificApplicationId.addAvp(Avp.AUTH_APPLICATION_ID, getApplicationId().getAuthAppId(), true); + } + // [ Result-Code ] + // [ Experimental-Result ] + // { Auth-Session-State } + if (set.getAvp(Avp.AUTH_SESSION_STATE) == null) { + set.addAvp(Avp.AUTH_SESSION_STATE, 1); + } + + // [ User-Name ] + String userName = getUserName(); + if (userName != null) { + set.addAvp(Avp.USER_NAME, userName, 10415, true, false, false); + } + + // [ MSISDN ] + byte[] msisdn = getMSISDN(); + if (msisdn != null){ + set.addAvp(Avp.MSISDN, msisdn, 10415, true, false); + } + + // [ LMSI ] + byte[] lmsi = getLMSI(); + if (lmsi != null){ + set.addAvp(Avp.LMSI, lmsi, 10415, true, false); + } + +/* + Serving-Node ::= + [ SGSN-Number ] + [ SGSN-Name ] + [ SGSN-Realm ] + [ MME-Name ] + [ MME-Realm ] + [ MSC-Number ] + [ 3GPP-AAA-Server-Name ] + [ LCS-Capabilities-Sets ] + [ GMLC-Address ] + *[AVP] + +*/ + AvpSet servingNode = set.addGroupedAvp(Avp.SERVING_NODE, 10415, true, false); + byte[] sgsnNumber = getSGSNNumber(); + String sgsnName= getSGSNName(); + String sgsnRealm = getSGSNRealm(); + String mmeName = getMMEName(); + String mmeRealm = getMMERealm(); + byte[] mscNumber = getMSCNumber(); + String tgppAAAServerName= get3GPPAAAServerName(); + long lcsCapabilitiesSet = getLCSCapabilitiesSets(); + java.net.InetAddress gmlcAddress = getGMLCAddress(); + + if (sgsnNumber != null){ + servingNode.addAvp(Avp.SGSN_NUMBER, sgsnNumber, 10415, false, false); + } + if (sgsnName != null){ + servingNode.addAvp(Avp.SGSN_NAME, sgsnName, 10415, false, false, false); + } + if (sgsnRealm != null){ + servingNode.addAvp(Avp.SGSN_REALM, sgsnRealm, 10415, false, false, false); + } + if (mmeName != null){ + servingNode.addAvp(Avp.MME_NAME, mmeName, 10415, false, false, false); + } + if (mmeRealm != null){ + servingNode.addAvp(Avp.MME_REALM, mmeRealm, 10415, false, false, false); + } + if (mscNumber != null){ + servingNode.addAvp(Avp.MSC_NUMBER, mscNumber, 10415, false, false); + } + if (tgppAAAServerName != null){ + servingNode.addAvp(Avp.TGPP_AAA_SERVER_NAME, tgppAAAServerName, 10415, false, false, false); + } + if (lcsCapabilitiesSet != -1){ + servingNode.addAvp(Avp.LCS_CAPABILITIES_SETS, lcsCapabilitiesSet, 10415, false, false, true); + } + if (gmlcAddress != null){ + servingNode.addAvp(Avp.GMLC_ADDRESS, gmlcAddress, 10415, false, false); + } + +/* + Additional-Serving-Node ::= + [ SGSN-Number ] + [ MME-Name ] + [ SGSN-Name ] + [ SGSN-Realm ] + [ MME-Realm ] + [ MSC-Number ] + [ 3GPP-AAA-Server-Name ] + [ LCS-Capabilities-Sets ] + [ GMLC-Address ] + *[AVP] +*/ + AvpSet additionalServingNode = set.addGroupedAvp(Avp.ADDITIONAL_SERVING_NODE, 10415, true, false); + byte[] additionalSGSNNumber = getAdditionalSGSNNumber(); + String additionalSGSNName = getAdditionalSGSNName(); + String additionalSGSNRealm = getAdditionalSGSNRealm(); + String additionalMMEName = getAdditionalMMEName(); + String additionalMMERealm = getAdditionalMMERealm(); + byte[] additionalMSCNumber = getAdditionalMSCNumber(); + String additional3GPPAAAServerName = getAdditional3GPPAAAServerName(); + long additionalLCSCapabilitiesSets = getAdditionalLCSCapabilitiesSets(); + java.net.InetAddress additionalGMLCAddress = getAdditionalGMLCAddress(); + + if (additionalSGSNNumber != null){ + additionalServingNode.addAvp(Avp.SGSN_NUMBER, additionalSGSNNumber, 10415, false, false); + } + if (additionalSGSNName != null){ + additionalServingNode.addAvp(Avp.SGSN_NAME, additionalSGSNName, 10415, false, false, false); + } + if (additionalSGSNRealm != null){ + additionalServingNode.addAvp(Avp.SGSN_REALM, additionalSGSNRealm, 10415, false, false, false); + } + if (additionalMMEName != null){ + additionalServingNode.addAvp(Avp.MME_NAME, additionalMMEName, 10415, false, false, false); + } + if (additionalMMERealm != null){ + additionalServingNode.addAvp(Avp.MME_REALM, additionalMMERealm, 10415, false, false, false); + } + if (additionalMSCNumber != null){ + additionalServingNode.addAvp(Avp.MSC_NUMBER, additionalMSCNumber, 10415, false, false); + } + if (additional3GPPAAAServerName != null){ + additionalServingNode.addAvp(Avp.TGPP_AAA_SERVER_NAME, additional3GPPAAAServerName, 10415, false, false, false); + } + if (additionalLCSCapabilitiesSets != -1){ + additionalServingNode.addAvp(Avp.LCS_CAPABILITIES_SETS, additionalLCSCapabilitiesSets, 10415, false, false, true); + } + if (additionalGMLCAddress != null){ + additionalServingNode.addAvp(Avp.GMLC_ADDRESS, additionalGMLCAddress, 10415, false, false); + } + + // [ PPR-Address ] + java.net.InetAddress pprAddress = getPPRAddress(); + if (pprAddress != null){ + set.addAvp(Avp.PPR_ADDRESS, pprAddress, 10415, true, false); + } + + //[ RIA-Flags ] + long riafLags = getRIAFLags(); + if (riafLags != -1){ + set.addAvp(Avp.RIA_FLAGS, riafLags, 10415, true, false, true); + } + + return ria; + } + +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/Client.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/Client.java new file mode 100644 index 000000000..7b116e19f --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/Client.java @@ -0,0 +1,119 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.stack.functional.slh.base; + +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.mobicents.diameter.stack.functional.Utils; +import org.mobicents.diameter.stack.functional.slh.AbstractClient; + +/** + * + * @author Fernando Mendioroz + * + */ +public class Client extends AbstractClient { + + protected boolean receivedRIA; + protected boolean sentRIR; + + public Client() { + } + + public void sendLCSRoutingInfoRequest() throws Exception { + LCSRoutingInfoRequest rir = super.createRIR(super.clientSLhSession); + super.clientSLhSession.sendLCSRoutingInfoRequest(rir); + Utils.printMessage(log, super.stack.getDictionary(), rir.getMessage(), true); + this.sentRIR = true; + } + + /* (non-Javadoc) + * @see org.mobicents.diameter.stack.functional.slh.AbstractImmediateClient#doLCSRoutingInfoAnswerEvent( + * org.jdiameter.api.slh.ClientSLhSession, org.jdiameter.api.slh.events.LCSRoutingInfoRequest, org.jdiameter.api.slh.events.LCSRoutingInfoAnswer) + */ + @Override + public void doLCSRoutingInfoAnswerEvent(ClientSLhSession session, LCSRoutingInfoRequest request, LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), false); + + if (this.receivedRIA) { + fail("Received RIA more than once", null); + return; + } + this.receivedRIA = true; + } + + @Override + protected String getUserName() { + // Information Element IMSI Mapped to AVP User-Name + String imsi = "748039876543210"; + return imsi; + } + + @Override + protected byte[] getMSISDN() { + String msisdnString = "59899077937"; + byte[] msisdn = msisdnString.getBytes(); + return msisdn; + } + + @Override + protected byte[] getGMLCNumber() { + String gmlcNumberString = "759834279"; + byte[] gmlcNumber = gmlcNumberString.getBytes(); + return gmlcNumber; + } + + public boolean isReceivedRIA() { + return receivedRIA; + } + + public boolean isSentRIR() { + return sentRIR; + } +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/base/RoSessionBasicFlowIdleTest.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/SLhSessionBasicFlowTest.java similarity index 60% rename from testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/base/RoSessionBasicFlowIdleTest.java rename to testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/SLhSessionBasicFlowTest.java index 5ece58381..f8d1a52f1 100644 --- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/ro/base/RoSessionBasicFlowIdleTest.java +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/SLhSessionBasicFlowTest.java @@ -1,6 +1,6 @@ /* * TeleStax, Open Source Cloud Communications - * Copyright 2011-2017, TeleStax Inc. and individual contributors + * Copyright 2011-2016, TeleStax Inc. and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify @@ -15,9 +15,32 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see - */ + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ -package org.mobicents.diameter.stack.functional.ro.base; +package org.mobicents.diameter.stack.functional.slh.base; import static org.junit.Assert.fail; @@ -43,25 +66,25 @@ import org.junit.runners.Parameterized.Parameters; /** - * + * @author Fernando Mendioroz * @author Alexandre Mendonca * @author Bartosz Baranowski */ @RunWith(Parameterized.class) -public class RoSessionBasicFlowIdleTest { - +public class SLhSessionBasicFlowTest { + // TODO: add test on replicated nodes ? private Client clientNode; private Server serverNode1; private URI clientConfigURI; private URI serverNode1ConfigURI; /** - * @param clientNode - * @param node1 - * @param node2 - * @param serverCount + * @param clientConfigUrl + * @param serverNode1ConfigURL + * // @param node2 + * // @param serverCount */ - public RoSessionBasicFlowIdleTest(String clientConfigUrl, String serverNode1ConfigURL) throws Exception { + public SLhSessionBasicFlowTest(String clientConfigUrl, String serverNode1ConfigURL) throws Exception { super(); this.clientConfigURI = new URI(clientConfigUrl); this.serverNode1ConfigURI = new URI(serverNode1ConfigURL); @@ -128,56 +151,33 @@ public void tearDown() { } @Test - public void testBasicFlow() throws Exception { + public void testLCSRoutingInfo() throws Exception { try { // pain of parameter tests :) ? - clientNode.sendInitial(); - waitForMessage(); - - serverNode1.sendInitial(); + clientNode.sendLCSRoutingInfoRequest(); waitForMessage(); - clientNode.sendInterim(); - waitForMessage(); - - serverNode1.sendInterim(); - waitForMessage(5500); // we wait a bit more so session expires with idle - - clientNode.sendTermination(); - waitForMessage(); - - serverNode1.sendTermination(); + serverNode1.sendLCSRoutingInfoAnswer(); waitForMessage(); } catch (Exception e) { - // in case the session expired even before receiving the termination - if (!"Request: null".equals(e.getMessage())) { - e.printStackTrace(); - fail(e.toString()); - } + e.printStackTrace(); + fail(e.toString()); } - if (!clientNode.isReceiveINITIAL()) { - StringBuilder sb = new StringBuilder("Did not receive INITIAL! "); - sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); + if (!serverNode1.isReceivedRIR()) { + StringBuilder sb = new StringBuilder("Did not receive RIR! "); + sb.append("Server ER:\n").append(serverNode1.createErrorReport(this.serverNode1.getErrors())); fail(sb.toString()); } - if (!clientNode.isReceiveINTERIM()) { - StringBuilder sb = new StringBuilder("Did not receive INTERIM! "); + if (!clientNode.isReceivedRIA()) { + StringBuilder sb = new StringBuilder("Did not receive RIA! "); sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); fail(sb.toString()); } - if (!clientNode.isReceiveTERMINATE()) { - // we don't fail here, we wanted session to be terminated when server tries to receive/send TERMINATE - } - if (clientNode.isReceiveTERMINATE()) { - StringBuilder sb = new StringBuilder("Did receive TERMINATE, should not, session should have been terminated by idle! "); - sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); - fail(sb.toString()); - } if (!clientNode.isPassed()) { StringBuilder sb = new StringBuilder(); sb.append("Client ER:\n").append(clientNode.createErrorReport(this.clientNode.getErrors())); @@ -185,54 +185,39 @@ public void testBasicFlow() throws Exception { fail(sb.toString()); } - if (!serverNode1.isReceiveINITIAL()) { - StringBuilder sb = new StringBuilder("Did not receive INITIAL! "); - sb.append("Server ER:\n").append(serverNode1.createErrorReport(this.serverNode1.getErrors())); - - fail(sb.toString()); - } - else if (!serverNode1.isReceiveINTERIM()) { - StringBuilder sb = new StringBuilder("Did not receive INTERIM! "); + if (!serverNode1.isPassed()) { + StringBuilder sb = new StringBuilder(); sb.append("Server ER:\n").append(serverNode1.createErrorReport(this.serverNode1.getErrors())); fail(sb.toString()); } - else if (!serverNode1.isReceiveTERMINATE()) { - // we don't fail here, we wanted session to be terminated when server tries to receive/send TERMINATE - } - if (!serverNode1.isPassed()) { - // we don't fail here, we wanted session to be terminated when server tries to receive/send TERMINATE - } } @Parameters public static Collection data() { - String client = "configurations/functional-ro/config-client.xml"; - String server1 = "configurations/functional-ro/config-server-node1-session-idle.xml"; - String replicatedClient = "configurations/functional-ro/replicated-config-client.xml"; - String replicatedServer1 = "configurations/functional-ro/replicated-config-server-node1.xml"; + String client = "configurations/functional-slh/config-client.xml"; + String server1 = "configurations/functional-slh/config-server-node1.xml"; + + //String replicatedClient = "configurations/functional-slh/replicated-config-client.xml"; + //String replicatedServer1 = "configurations/functional-slh/replicated-config-server-node1.xml"; - Class t = RoSessionBasicFlowIdleTest.class; + Class t = SLhSessionBasicFlowTest.class; client = t.getClassLoader().getResource(client).toString(); server1 = t.getClassLoader().getResource(server1).toString(); - replicatedClient = t.getClassLoader().getResource(replicatedClient).toString(); - replicatedServer1 = t.getClassLoader().getResource(replicatedServer1).toString(); + //replicatedClient = t.getClassLoader().getResource(replicatedClient).toString(); + //replicatedServer1 = t.getClassLoader().getResource(replicatedServer1).toString(); - return Arrays.asList(new Object[][] { { client, server1 }/*, { replicatedClient, replicatedServer1 }*/ }); + return Arrays.asList(new Object[][] { { client, server1 }/*, { replicatedClient, replicatedServer1 } */}); } - private void waitForMessage(long time) { + private void waitForMessage() { try { - Thread.sleep(time); + Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } - private void waitForMessage() { - waitForMessage(2000); - } - } diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/Server.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/Server.java new file mode 100644 index 000000000..5a74da9cc --- /dev/null +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/functional/slh/base/Server.java @@ -0,0 +1,318 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, TeleStax Inc. and individual contributors + * by the @authors tag. + * + * This program is free software: you can redistribute it and/or modify + * under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * JBoss, Home of Professional Open Source + * Copyright 2007-2011, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ + +package org.mobicents.diameter.stack.functional.slh.base; + +import org.jdiameter.api.Answer; +import org.jdiameter.api.IllegalDiameterStateException; +import org.jdiameter.api.InternalException; +import org.jdiameter.api.NetworkReqListener; +import org.jdiameter.api.OverloadException; +import org.jdiameter.api.Request; +import org.jdiameter.api.RouteException; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; +import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; +import org.mobicents.diameter.stack.functional.Utils; +import org.mobicents.diameter.stack.functional.slh.AbstractServer; + +import java.net.UnknownHostException; + +/** + * + * @author Fernando Mendioroz + * + */ +public class Server extends AbstractServer { + + protected boolean receivedRIR; + protected boolean sentRIA; + + protected LCSRoutingInfoRequest request; + + public void sendLCSRoutingInfoAnswer() throws Exception { + if (!receivedRIR || request == null) { + fail("Did not receive RIR or answer already sent.", null); + throw new Exception("Did not receive RIR or answer already sent. Request: " + this.request); + } + + LCSRoutingInfoAnswer ria = super.createRIA(request, 2001); + + super.serverSLhSession.sendLCSRoutingInfoAnswer(ria); + + this.sentRIA = true; + request = null; + Utils.printMessage(log, super.stack.getDictionary(), ria.getMessage(), true); + } + + /* (non-Javadoc) + * @see org.mobicents.diameter.stack.functional.TBase#processRequest(org.jdiameter.api.Request) + */ + @Override + public Answer processRequest(Request request) { + int code = request.getCommandCode(); + if (code != LCSRoutingInfoRequest.code) { + fail("Received Request with code not used by SLh!. Code[" + request.getCommandCode() + "]", null); + return null; + } + if (super.serverSLhSession != null) { + // do fail? + fail("Received Request in base listener, not in app specific!" + code, null); + } else { + try { + + super.serverSLhSession = this.sessionFactory.getNewAppSession(request.getSessionId(), getApplicationId(), ServerSLhSession.class, (Object) null); + ((NetworkReqListener) this.serverSLhSession).processRequest(request); + + } catch (Exception e) { + e.printStackTrace(); + fail(null, e); + } + } + return null; + } + @Override + public void doLCSRoutingInfoRequestEvent(ServerSLhSession session, LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + if (this.receivedRIR) { + fail("Received RIR more than once", null); + return; + } + this.receivedRIR = true; + this.request = request; + } + + @Override + protected String getUserName() { + // Information Element IMSI Mapped to AVP User-Name + String imsi = "748039876543210"; + return imsi; + } + + @Override + protected byte[] getMSISDN() { + String msisdnString = "59899077937"; + byte[] msisdn = msisdnString.getBytes(); + return msisdn; + } + + @Override + protected byte[] getLMSI() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.2 + The LMSI AVP is of type OctetString and it shall contain the Local Mobile Station Identity (LMSI) allocated by the VLR, as defined in 3GPP TS 23.003 + */ + String lmsiString = "748031234567890"; + byte[] lmsi = lmsiString.getBytes(); + return lmsi; + } + + @Override + protected byte[] getSGSNNumber() { + String sgsnNumString = "59899004501"; + byte[] sgsnNumber = sgsnNumString.getBytes(); + return sgsnNumber; + } + + @Override + protected String getSGSNName() { + String sgsnName = "SGSN01"; + return sgsnName; + } + + @Override + protected String getSGSNRealm() { + String sgsnRealm = "sgsn.restcomm.com"; + return sgsnRealm; + } + + @Override + protected String getMMEName() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.4 + TThe MME-Name AVP is of type DiameterIdentity and it shall contain the Diameter identity of the serving MME. + */ + String mmeName = "MME710"; + return mmeName; + } + + @Override + protected String getMMERealm() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.12 + The MME-Realm AVP is of type DiameterIdentity and it shall contain the Diameter Realm Identity of the serving MME. + */ + String mmeRealm = "mme.restcomm.com"; + return mmeRealm; + } + + @Override + protected byte[] getMSCNumber() { + String mscNumString = "59899001207"; + byte[] mscNumber = mscNumString.getBytes(); + return mscNumber; + } + + @Override + protected String get3GPPAAAServerName() { + String tgppAAAServerName = "aaa.restcomm.com"; + return tgppAAAServerName; + } + + @Override + protected long getLCSCapabilitiesSets() { + long lcsCapabilitiesSets = 99900123L; + return lcsCapabilitiesSets; + } + + @Override + protected byte[] getAdditionalSGSNNumber() { + String sgsnNumString = "59899004502"; + byte[] sgsnNumber = sgsnNumString.getBytes(); + return sgsnNumber; + } + + @Override + protected String getAdditionalSGSNName() { + String sgsnName = "SGSN02"; + return sgsnName; + } + + @Override + protected String getAdditionalSGSNRealm() { + String sgsnRealm = "sgsn2.restcomm.com"; + return sgsnRealm; + } + + @Override + protected String getAdditionalMMEName() { + String mmeName = "MME712"; + return mmeName; + } + + @Override + protected String getAdditionalMMERealm() { + String mmeRealm = "mme2.restcomm.com"; + return mmeRealm; + } + + @Override + protected byte[] getAdditionalMSCNumber() { + String mscNumString = "59899001210"; + byte[] mscNumber = mscNumString.getBytes(); + return mscNumber; + } + + @Override + protected String getAdditional3GPPAAAServerName() { + String tgppAAAServerName = "aaa2.restcomm.com"; + return tgppAAAServerName; + } + + @Override + protected long getAdditionalLCSCapabilitiesSets() { + long lcsCapabilitiesSets = 88800123L; + return lcsCapabilitiesSets; + } + + @Override + protected java.net.InetAddress getAdditionalGMLCAddress() { + try { + java.net.InetAddress gmlcAddress = java.net.InetAddress.getLocalHost(); + return gmlcAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected java.net.InetAddress getGMLCAddress() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.7 + The GMLC-Address AVP is of type Address and shall contain the IPv4 or IPv6 address of H-GMLC or the V-GMLC associated with the serving node. + */ + try { + java.net.InetAddress gmlcAddress = java.net.InetAddress.getLocalHost(); + return gmlcAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected java.net.InetAddress getPPRAddress() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.9 + The PPR-Address AVP is of type Address and contains the IPv4 or IPv6 address of the Privacy Profile Register for the targeted user + */ + try { + java.net.InetAddress pprAddress = java.net.InetAddress.getLocalHost(); + return pprAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected long getRIAFLags() { + /* + 3GPP TS 29.173 v13.0.0 section 6.4.15 + Bit Event Type Description + 0 Combined-MME/SGSN-Supporting-Optimized-LCS-Proc This bit, when set, indicates that the UE is served by the MME and the SGSN parts of the same + combined MME/SGSN and this combined MME/SGSN supports the optimized LCS procedure. + */ + long riaFlags = 1L; + return riaFlags; + } + + public boolean isReceivedRIR() { + return receivedRIR; + } + + public boolean isSentRIA() { + return sentRIA; + } + +} diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/parser/AvpSetTest.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/parser/AvpSetTest.java index 0bcdc1641..e01527038 100644 --- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/parser/AvpSetTest.java +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/parser/AvpSetTest.java @@ -59,27 +59,5 @@ public void remove2Test() throws IOException, AvpDataException { } - @Test(timeout = 500) - public void decodeWithVendorIdZero() throws IOException, AvpDataException { - byte avpCode = 123; - byte vendorId = 1; - byte[] avpSetBytes = new byte[] { - 0, 0, 1, 3, 64, 0, 0, 12, 0, 0, 0, 3, 0, 0, 1, 41, 0, 0, 0, 20, 0, 0, 1, 42, 0, 0, 0, 12, 0, 0, 7, -47, 0, 0, 0, - 1, 0, 0, 0, 26, 109, 111, 98, 105, 99, 101, 110, 116, 115, 45, 100, 105, 97, 109, 101, 116, 101, 114, 0, 0, 0, - 0, 0, avpCode, -64, 0, 0, 15, 0, 0, 0, vendorId, 88, 88, 88, 0 - }; - AvpSet avpVendor1 = elementParser.decodeAvpSet(avpSetBytes); - Assert.assertNotNull(avpVendor1.getAvp(123, 1)); - - vendorId = 0; - avpSetBytes = new byte[] { - 0, 0, 1, 3, 64, 0, 0, 12, 0, 0, 0, 3, 0, 0, 1, 41, 0, 0, 0, 20, 0, 0, 1, 42, 0, 0, 0, 12, 0, 0, 7, -47, 0, 0, 0, - 1, 0, 0, 0, 26, 109, 111, 98, 105, 99, 101, 110, 116, 115, 45, 100, 105, 97, 109, 101, 116, 101, 114, 0, 0, 0, - 0, 0, avpCode, -64, 0, 0, 15, 0, 0, 0, vendorId, 88, 88, 88, 0 - }; - AvpSet avpVendor0 = elementParser.decodeAvpSet(avpSetBytes); - Assert.assertNotNull(avpVendor0.getAvp(123, 0)); - } - } diff --git a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/sessions/SessionsWithAppIdTest.java b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/sessions/SessionsWithAppIdTest.java index 33b8150eb..15470388f 100644 --- a/testsuite/tests/src/test/java/org/mobicents/diameter/stack/sessions/SessionsWithAppIdTest.java +++ b/testsuite/tests/src/test/java/org/mobicents/diameter/stack/sessions/SessionsWithAppIdTest.java @@ -47,7 +47,12 @@ import org.jdiameter.api.s13.ServerS13Session; import org.jdiameter.api.sh.ClientShSession; import org.jdiameter.api.sh.ServerShSession; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ServerSLgSession; import org.jdiameter.client.api.ISessionFactory; +import org.jdiameter.common.api.app.IAppSessionFactory; import org.jdiameter.common.impl.app.acc.AccSessionFactoryImpl; import org.jdiameter.common.impl.app.auth.AuthSessionFactoryImpl; import org.jdiameter.common.impl.app.cca.CCASessionFactoryImpl; @@ -58,6 +63,8 @@ import org.jdiameter.common.impl.app.ro.RoSessionFactoryImpl; import org.jdiameter.common.impl.app.s13.S13SessionFactoryImpl; import org.jdiameter.common.impl.app.sh.ShSessionFactoryImpl; +import org.jdiameter.common.impl.app.slh.SLhSessionFactoryImpl; +import org.jdiameter.common.impl.app.slg.SLgSessionFactoryImpl; import org.jdiameter.server.impl.StackImpl; import org.junit.Assert; import org.junit.Test; @@ -85,6 +92,8 @@ public class SessionsWithAppIdTest { private static final ApplicationId GQ_APPID = ApplicationId.createByAuthAppId(10415, 16777222); private static final ApplicationId GX_APPID = ApplicationId.createByAuthAppId(10415, 16777224); private static final ApplicationId S13_APPID = ApplicationId.createByAuthAppId(10415, 16777252); + private static final ApplicationId SLh_APPID = ApplicationId.createByAuthAppId(10415, 16777291); + private static final ApplicationId SLg_APPID = ApplicationId.createByAuthAppId(10415, 16777255); static { @@ -287,4 +296,40 @@ public void testS13ServerSessionHasAppId() throws Exception { ApplicationId sessionAppId = session.getSessionAppId(); Assert.assertEquals("Session Application-Id should be the same as indicated.", S13_APPID, sessionAppId); } + + @Test + public void testSLhClientSessionHasAppId() throws Exception { + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLhSession.class, new SLhSessionFactoryImpl(sessionFactory)); + ClientSLhSession session = sessionFactory.getNewAppSession("accesspoint7.acme.com;1876543210;" + lowSessionId++, SLh_APPID, ClientSLhSession.class); + + ApplicationId sessionAppId = session.getSessionAppId(); + Assert.assertEquals("Session Application-Id should be the same as indicated.", SLh_APPID, sessionAppId); + } + + @Test + public void testSLhServerSessionHasAppId() throws Exception { + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLhSession.class, new SLhSessionFactoryImpl(sessionFactory)); + ServerSLhSession session = sessionFactory.getNewAppSession("accesspoint7.acme.com;1876543210;" + lowSessionId++, SLh_APPID, ServerSLhSession.class); + + ApplicationId sessionAppId = session.getSessionAppId(); + Assert.assertEquals("Session Application-Id should be the same as indicated.", SLh_APPID, sessionAppId); + } + + @Test + public void testSLgClientSessionHasAppId() throws Exception { + ((ISessionFactory) sessionFactory).registerAppFacory(ClientSLgSession.class, new SLgSessionFactoryImpl(sessionFactory)); + ClientSLgSession session = sessionFactory.getNewAppSession("accesspoint7.acme.com;1876543210;" + lowSessionId++, SLg_APPID, ClientSLgSession.class); + + ApplicationId sessionAppId = session.getSessionAppId(); + Assert.assertEquals("Session Application-Id should be the same as indicated.", SLg_APPID, sessionAppId); + } + + @Test + public void testSLgServerSessionHasAppId() throws Exception { + ((ISessionFactory) sessionFactory).registerAppFacory(ServerSLgSession.class, new SLgSessionFactoryImpl(sessionFactory)); + ServerSLgSession session = sessionFactory.getNewAppSession("accesspoint7.acme.com;1876543210;" + lowSessionId++, SLg_APPID, ServerSLgSession.class); + + ApplicationId sessionAppId = session.getSessionAppId(); + Assert.assertEquals("Session Application-Id should be the same as indicated.", SLg_APPID, sessionAppId); + } } diff --git a/testsuite/tests/src/test/resources/configurations/functional-slg/config-client.xml b/testsuite/tests/src/test/resources/configurations/functional-slg/config-client.xml new file mode 100644 index 000000000..985e93b00 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slg/config-client.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-ro/config-server-node1-session-idle.xml b/testsuite/tests/src/test/resources/configurations/functional-slg/config-server-node1.xml similarity index 88% rename from testsuite/tests/src/test/resources/configurations/functional-ro/config-server-node1-session-idle.xml rename to testsuite/tests/src/test/resources/configurations/functional-slg/config-server-node1.xml index a414482eb..671a3718b 100644 --- a/testsuite/tests/src/test/resources/configurations/functional-ro/config-server-node1-session-idle.xml +++ b/testsuite/tests/src/test/resources/configurations/functional-slg/config-server-node1.xml @@ -13,8 +13,8 @@ - - + + @@ -29,13 +29,13 @@ - + @@ -45,8 +45,8 @@ - - + + @@ -55,4 +55,4 @@ - \ No newline at end of file + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slg/config-server-node2.xml b/testsuite/tests/src/test/resources/configurations/functional-slg/config-server-node2.xml new file mode 100644 index 000000000..19f4e04cf --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slg/config-server-node2.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-client.xml b/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-client.xml new file mode 100644 index 000000000..af34d251d --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-client.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-server-node1.xml b/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-server-node1.xml new file mode 100644 index 000000000..8d0e546a5 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-server-node1.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-server-node2.xml b/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-server-node2.xml new file mode 100644 index 000000000..370776e20 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slg/replicated-config-server-node2.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slh/config-client.xml b/testsuite/tests/src/test/resources/configurations/functional-slh/config-client.xml new file mode 100644 index 000000000..b6dfded19 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slh/config-client.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slh/config-server-node1.xml b/testsuite/tests/src/test/resources/configurations/functional-slh/config-server-node1.xml new file mode 100644 index 000000000..06f228923 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slh/config-server-node1.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slh/config-server-node2.xml b/testsuite/tests/src/test/resources/configurations/functional-slh/config-server-node2.xml new file mode 100644 index 000000000..e54f04e89 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slh/config-server-node2.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-client.xml b/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-client.xml new file mode 100644 index 000000000..65ec0c5d2 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-client.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-server-node1.xml b/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-server-node1.xml new file mode 100644 index 000000000..6041e7ed8 --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-server-node1.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-server-node2.xml b/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-server-node2.xml new file mode 100644 index 000000000..73668228d --- /dev/null +++ b/testsuite/tests/src/test/resources/configurations/functional-slh/replicated-config-server-node2.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/tests/src/test/resources/dictionary.xml b/testsuite/tests/src/test/resources/dictionary.xml index 6f7c02bc2..a63b6aaee 100644 --- a/testsuite/tests/src/test/resources/dictionary.xml +++ b/testsuite/tests/src/test/resources/dictionary.xml @@ -7867,4 +7867,637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testsuite/tests/src/test/resources/jdiameter-infinispan.xml b/testsuite/tests/src/test/resources/jdiameter-infinispan.xml deleted file mode 100644 index 97d19677e..000000000 --- a/testsuite/tests/src/test/resources/jdiameter-infinispan.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/testsuite/tests/src/test/resources/validator.xml b/testsuite/tests/src/test/resources/validator.xml index 33f1ad3c6..1cf21c6b6 100644 --- a/testsuite/tests/src/test/resources/validator.xml +++ b/testsuite/tests/src/test/resources/validator.xml @@ -2835,7 +2835,7 @@ Note: The AVP codes from 1119 to 1199 are reserved for TS 29.140 - + diff --git a/testsuite/tests/src/test/resources/validatorOff.xml b/testsuite/tests/src/test/resources/validatorOff.xml index 1dffc0f4c..5178d7471 100644 --- a/testsuite/tests/src/test/resources/validatorOff.xml +++ b/testsuite/tests/src/test/resources/validatorOff.xml @@ -2835,7 +2835,7 @@ Note: The AVP codes from 1119 to 1199 are reserved for TS 29.140 - +