Revision: ae0a0005a363
Author: [email protected] <[email protected]>
Date: Fri Aug 24 04:14:37 2012
Log: Issue 3:Allow mobicents SS7 stack to be configurable to use 5 or
8 bit SLS
http://code.google.com/p/jss7/source/detail?r=ae0a0005a363
Added:
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/RoutingLabelFormat.java
Deleted:
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/PointCodeFormat.java
Modified:
/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/DahdiMtp3UserPart.java
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferPrimitive.java
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferPrimitiveFactory.java
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3UserPart.java
/mtp/mtp-api/src/test/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferMessageTest.java
/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3UserPartBaseImpl.java
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutorTest.java
/service/src/main/config/jboss-beans.xml
=======================================
--- /dev/null
+++
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/RoutingLabelFormat.java
Fri Aug 24 04:14:37 2012
@@ -0,0 +1,72 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * 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.protocols.ss7.mtp;
+
+/**
+ * @author amit bhayani
+ *
+ */
+public enum RoutingLabelFormat {
+ ANSI_Sls8Bit("ANSI", 8), ANSI_Sls5Bit("ANSI", 5), ITU("ITU", 4),
Japan_TTC_DDI("Japan_TTC_DDI", 8), China("China", 8),
Japan_NTT("Japan_NTT", 8);
+
+ private final String format;
+ private final int slsLengthInBits;
+
+ private static final String FORMAT_ITU = "ITU";
+ private static final String FORMAT_ANSI = "ANSI";
+ private static final String FORMAT_Japan_TTC_DDI = "Japan_TTC_DDI";
+ private static final String FROMAT_China = "China";
+ private static final String FORMAT_Japan_NTT = "Japan_NTT";
+
+ private RoutingLabelFormat(String format, int slsLengthInBits) {
+ this.format = format;
+ this.slsLengthInBits = slsLengthInBits;
+ }
+
+ public String getFormat() {
+ return this.format;
+ }
+
+ /**
+ * @return the sls
+ */
+ protected int getSlsLengthInBits() {
+ return this.slsLengthInBits;
+ }
+
+ public static RoutingLabelFormat getInstance(String format) {
+ if (FORMAT_ITU.equals(format)) {
+ return ITU;
+ } else if (FORMAT_ANSI.equals(format)) {
+ return ANSI_Sls8Bit;
+ } else if (FORMAT_Japan_TTC_DDI.equals(format)) {
+ return Japan_TTC_DDI;
+ } else if (FROMAT_China.equals(format)) {
+ return China;
+ } else if (FORMAT_Japan_NTT.equals(format)) {
+ return Japan_NTT;
+ }
+
+ return null;
+ }
+
+}
=======================================
---
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/PointCodeFormat.java
Thu Aug 23 04:29:16 2012
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * TeleStax, Open Source Cloud Communications Copyright 2012.
- * 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.protocols.ss7.mtp;
-
-/**
- * @author amit bhayani
- *
- */
-public enum PointCodeFormat {
- ANSI("ANSI"), ITU("ITU"), Japan_TTC_DDI("Japan_TTC_DDI"), China("China"),
Japan_NTT("Japan_NTT");
-
- private final String format;
-
- private static final String FORMAT_ITU = "ITU";
- private static final String FORMAT_ANSI = "ANSI";
- private static final String FORMAT_Japan_TTC_DDI = "Japan_TTC_DDI";
- private static final String FROMAT_China = "China";
- private static final String FORMAT_Japan_NTT = "Japan_NTT";
-
- private PointCodeFormat(String format) {
- this.format = format;
- }
-
- public String getFormat() {
- return this.format;
- }
-
- public static PointCodeFormat getInstance(String format) {
- if (FORMAT_ITU.equals(format)) {
- return ITU;
- } else if (FORMAT_ANSI.equals(format)) {
- return ANSI;
- } else if (FORMAT_Japan_TTC_DDI.equals(format)) {
- return Japan_TTC_DDI;
- } else if (FROMAT_China.equals(format)) {
- return China;
- } else if (FORMAT_Japan_NTT.equals(format)) {
- return Japan_NTT;
- }
-
- return null;
- }
-
-}
=======================================
---
/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/DahdiMtp3UserPart.java
Thu Aug 23 04:26:00 2012
+++
/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/DahdiMtp3UserPart.java
Fri Aug 24 04:14:37 2012
@@ -28,7 +28,7 @@
import org.mobicents.protocols.ss7.mtp.Mtp3TransferPrimitiveFactory;
import org.mobicents.protocols.ss7.mtp.Mtp3UserPart;
import org.mobicents.protocols.ss7.mtp.Mtp3UserPartListener;
-import org.mobicents.protocols.ss7.mtp.PointCodeFormat;
+import org.mobicents.protocols.ss7.mtp.RoutingLabelFormat;
/**
*
@@ -71,40 +71,23 @@
}
/* (non-Javadoc)
- * @see org.mobicents.protocols.ss7.mtp.Mtp3UserPart#getSLSLength()
+ * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#getRoutingLabelFormat()
*/
@Override
- public int getSlsLength() {
+ public RoutingLabelFormat getRoutingLabelFormat() {
// TODO Auto-generated method stub
- return 0;
+ return null;
}
-
/* (non-Javadoc)
- * @see org.mobicents.protocols.ss7.mtp.Mtp3UserPart#setSLSLength(int)
+ * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#setRoutingLabelFormat(org.mobicents.protocols.ss7.mtp.RoutingLabelFormat)
*/
@Override
- public void setSlsLength(int arg0) {
+ public void setRoutingLabelFormat(RoutingLabelFormat arg0) {
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#getPointCodeFormat()
- */
- @Override
- public PointCodeFormat getPointCodeFormat() {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#setPointCodeFormat(org.mobicents.protocols.ss7.mtp.PointCodeFormat)
- */
- @Override
- public void setPointCodeFormat(PointCodeFormat arg0) {
- // TODO Auto-generated method stub
-
- }
}
=======================================
---
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferPrimitive.java
Thu Aug 23 04:29:16 2012
+++
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferPrimitive.java
Fri Aug 24 04:14:37 2012
@@ -37,10 +37,9 @@
protected final int sls;
protected final byte[] data;
- private final PointCodeFormat pointCodeFormat;
- private final int slsLength;
+ private final RoutingLabelFormat pointCodeFormat;
- protected Mtp3TransferPrimitive(int si, int ni, int mp, int opc, int dpc,
int sls, byte[] data, PointCodeFormat pointCodeFormat, int slsLength) {
+ protected Mtp3TransferPrimitive(int si, int ni, int mp, int opc, int dpc,
int sls, byte[] data, RoutingLabelFormat pointCodeFormat) {
this.si = si;
this.ni = ni;
this.mp = mp;
@@ -50,7 +49,6 @@
this.data = data;
this.pointCodeFormat = pointCodeFormat;
- this.slsLength = slsLength;
}
public int getSi() {
@@ -106,7 +104,7 @@
break;
- case ANSI:
+ case ANSI_Sls8Bit:
res = new byte[this.data.length + 8];
// sio
=======================================
---
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferPrimitiveFactory.java
Thu Aug 23 04:29:16 2012
+++
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferPrimitiveFactory.java
Fri Aug 24 04:14:37 2012
@@ -28,17 +28,14 @@
*/
public class Mtp3TransferPrimitiveFactory {
- private final PointCodeFormat pointCodeFormat;
+ private final RoutingLabelFormat pointCodeFormat;
- private final int slsLength;
-
- public Mtp3TransferPrimitiveFactory(PointCodeFormat pointCodeFormat, int
slsLength) {
+ public Mtp3TransferPrimitiveFactory(RoutingLabelFormat pointCodeFormat)
{
this.pointCodeFormat = pointCodeFormat;
- this.slsLength = slsLength;
}
public Mtp3TransferPrimitive createMtp3TransferPrimitive(int si, int ni,
int mp, int opc, int dpc, int sls, byte[] data) {
- Mtp3TransferPrimitive mtp3TransferPrimitive = new
Mtp3TransferPrimitive(si, ni, mp, opc, dpc, sls, data,
this.pointCodeFormat, this.slsLength);
+ Mtp3TransferPrimitive mtp3TransferPrimitive = new
Mtp3TransferPrimitive(si, ni, mp, opc, dpc, sls, data,
this.pointCodeFormat);
return mtp3TransferPrimitive;
}
@@ -72,7 +69,7 @@
data = new byte[msg.length - 5];
System.arraycopy(msg, 5, data, 0, data.length);
break;
- case ANSI:
+ case ANSI_Sls8Bit:
dpc = ((msg[3] & 0xff) << 16) | ((msg[2] & 0xff) << 8) | (msg[1] &
0xff);
opc = ((msg[6] & 0xff) << 16) | ((msg[5] & 0xff) << 8) | (msg[4] &
0xff);
sls = (msg[7] & 0xff);
@@ -86,7 +83,7 @@
// TODO : We don't support rest justyet
break;
}
- mtp3TransferPrimitive = new Mtp3TransferPrimitive(si, ni, mp, opc, dpc,
sls, data, this.pointCodeFormat, this.slsLength);
+ mtp3TransferPrimitive = new Mtp3TransferPrimitive(si, ni, mp, opc, dpc,
sls, data, this.pointCodeFormat);
return mtp3TransferPrimitive;
}
}
=======================================
---
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3UserPart.java
Thu Aug 23 04:29:16 2012
+++
/mtp/mtp-api/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3UserPart.java
Fri Aug 24 04:14:37 2012
@@ -30,7 +30,7 @@
*
*/
public interface Mtp3UserPart {
-
+
public void addMtp3UserPartListener(Mtp3UserPartListener listener);
public void removeMtp3UserPartListener(Mtp3UserPartListener listener);
@@ -40,28 +40,14 @@
*
* @return
*/
- public PointCodeFormat getPointCodeFormat();
+ public RoutingLabelFormat getRoutingLabelFormat();
/**
* Set PointCodeFormat
*
* @param length
*/
- public void setPointCodeFormat(PointCodeFormat pointCodeFormat);
-
- /**
- * Length of SLS in number of bits
- *
- * @return
- */
- public int getSlsLength();
-
- /**
- * Set length of SLS in number of bits
- *
- * @param slsLength
- */
- public void setSlsLength(int slsLength);
+ public void setRoutingLabelFormat(RoutingLabelFormat
routingLabelFormat);
/**
* Get the Mtp3TransferPrimitiveFactory
=======================================
---
/mtp/mtp-api/src/test/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferMessageTest.java
Thu Aug 23 04:29:16 2012
+++
/mtp/mtp-api/src/test/java/org/mobicents/protocols/ss7/mtp/Mtp3TransferMessageTest.java
Fri Aug 24 04:14:37 2012
@@ -53,7 +53,7 @@
@Test(groups = { "Mtp3TransferMessageTest", "decode" })
public void testDecode() throws Exception {
- Mtp3TransferPrimitiveFactory factory = new
Mtp3TransferPrimitiveFactory(PointCodeFormat.ITU, 4);
+ Mtp3TransferPrimitiveFactory factory = new
Mtp3TransferPrimitiveFactory(RoutingLabelFormat.ITU);
Mtp3TransferPrimitive msg =
factory.createMtp3TransferPrimitive(getMsg());
assertEquals(msg.getSi(), 3);
@@ -68,7 +68,7 @@
@Test(groups = { "Mtp3TransferMessageTest", "encode" })
public void testEncode() throws Exception {
- Mtp3TransferPrimitiveFactory factory = new
Mtp3TransferPrimitiveFactory(PointCodeFormat.ITU, 4);
+ Mtp3TransferPrimitiveFactory factory = new
Mtp3TransferPrimitiveFactory(RoutingLabelFormat.ITU);
Mtp3TransferPrimitive msg = factory.createMtp3TransferPrimitive(3, 2, 0,
2000, 1000, 10, this.getData());
byte[] res = msg.encodeMtp3();
=======================================
---
/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3UserPartBaseImpl.java
Thu Aug 23 04:29:16 2012
+++
/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3UserPartBaseImpl.java
Fri Aug 24 04:14:37 2012
@@ -53,11 +53,10 @@
private ExecutorService[] msgDeliveryExecutors;
// a thread for delivering PAUSE, RESUME and STATUS messages
private ExecutorService msgDeliveryExecutorSystem;
- private int slsTable[] = new int[maxSls];
+ private int slsTable[] = null;
- private PointCodeFormat pointCodeFormat = PointCodeFormat.ITU;
+ private RoutingLabelFormat routingLabelFormat = RoutingLabelFormat.ITU;
- private int slsLength = 5;
private Mtp3TransferPrimitiveFactory mtp3TransferPrimitiveFactory =
null;
public Mtp3UserPartBaseImpl() {
@@ -89,12 +88,12 @@
*/
@Override
public int getMaxUserDataLength(int dpc) {
- switch (this.pointCodeFormat) {
+ switch (this.routingLabelFormat) {
case ITU:
// For PC_FORMAT_14, the MTP3 Routing Label takes 4
bytes - OPC/DPC
// = 16 bits each and SLS = 4 bits
return 272 - 4;
- case ANSI:
+ case ANSI_Sls8Bit:
// For PC_FORMAT_24, the MTP3 Routing Label takes 6
bytes - OPC/DPC
// = 24 bits each and SLS = 8 bits
return 272 - 7;
@@ -105,21 +104,13 @@
}
}
- public PointCodeFormat getPointCodeFormat() {
- return this.pointCodeFormat;
+ public RoutingLabelFormat getRoutingLabelFormat() {
+ return this.routingLabelFormat;
}
- public void setPointCodeFormat(PointCodeFormat pointCodeFormat) {
- this.pointCodeFormat = pointCodeFormat;
+ public void setRoutingLabelFormat(RoutingLabelFormat
routingLabelFormat) {
+ this.routingLabelFormat = routingLabelFormat;
}
-
- public int getSlsLength() {
- return this.slsLength;
- }
-
- public void setSlsLength(int slsLength) {
- this.slsLength = slsLength;
- }
public Mtp3TransferPrimitiveFactory getMtp3TransferPrimitiveFactory() {
return this.mtp3TransferPrimitiveFactory;
@@ -130,28 +121,30 @@
if (this.isStarted)
return;
- if (!(this.pointCodeFormat == PointCodeFormat.ITU ||
this.pointCodeFormat == PointCodeFormat.ANSI)) {
+ if (!(this.routingLabelFormat == RoutingLabelFormat.ITU ||
this.routingLabelFormat == RoutingLabelFormat.ANSI_Sls8Bit)) {
throw new Exception("Invalid PointCodeFormat set. We support only ITU
or ANSI now");
}
- switch (this.slsLength) {
- case 4:
+ switch (this.routingLabelFormat) {
+ case ITU:
this.maxSls = 16;
this.slsFilter = 0x0f;
break;
- case 5:
+ case ANSI_Sls5Bit:
this.maxSls = 32;
this.slsFilter = 0x1f;
break;
- case 8:
+ case ANSI_Sls8Bit:
this.maxSls = 256;
this.slsFilter = 0xff;
break;
default:
- throw new Exception("Invalid SLS length set. Set 4 for max SLS to be 16
or 5 for max SLS to be 32 or 8 for max SLS to be 256");
+ throw new Exception("Invalid SLS length");
}
- this.mtp3TransferPrimitiveFactory = new
Mtp3TransferPrimitiveFactory(this.pointCodeFormat, this.slsLength);
+ this.slsTable = new int[maxSls];
+
+ this.mtp3TransferPrimitiveFactory = new
Mtp3TransferPrimitiveFactory(this.routingLabelFormat);
this.createSLSTable(this.deliveryTransferMessageThreadCount);
=======================================
---
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutorTest.java
Thu Aug 23 04:26:00 2012
+++
/sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/oam/SccpExecutorTest.java
Fri Aug 24 04:14:37 2012
@@ -22,8 +22,13 @@
package org.mobicents.protocols.ss7.sccp.impl.oam;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
import java.io.IOException;
+
import org.mobicents.protocols.ss7.indicator.GlobalTitleIndicator;
import org.mobicents.protocols.ss7.indicator.NatureOfAddress;
import org.mobicents.protocols.ss7.indicator.NumberingPlan;
@@ -32,7 +37,7 @@
import org.mobicents.protocols.ss7.mtp.Mtp3TransferPrimitiveFactory;
import org.mobicents.protocols.ss7.mtp.Mtp3UserPart;
import org.mobicents.protocols.ss7.mtp.Mtp3UserPartListener;
-import org.mobicents.protocols.ss7.mtp.PointCodeFormat;
+import org.mobicents.protocols.ss7.mtp.RoutingLabelFormat;
import org.mobicents.protocols.ss7.sccp.impl.ConcernedSignalingPointCode;
import org.mobicents.protocols.ss7.sccp.impl.RemoteSignalingPointCode;
import org.mobicents.protocols.ss7.sccp.impl.RemoteSubSystem;
@@ -870,37 +875,19 @@
}
/* (non-Javadoc)
- * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#getSLSLength()
+ * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#getRoutingLabelFormat()
*/
@Override
- public int getSlsLength() {
+ public RoutingLabelFormat getRoutingLabelFormat() {
// TODO Auto-generated method stub
- return 0;
- }
-
- /* (non-Javadoc)
- * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#setSLSLength(int)
- */
- @Override
- public void setSlsLength(int arg0) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#getPointCodeFormat()
- */
- @Override
- public PointCodeFormat getPointCodeFormat() {
- // TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
- * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#setPointCodeFormat(org.mobicents.protocols.ss7.mtp.PointCodeFormat)
+ * @see
org.mobicents.protocols.ss7.mtp.Mtp3UserPart#setRoutingLabelFormat(org.mobicents.protocols.ss7.mtp.RoutingLabelFormat)
*/
@Override
- public void setPointCodeFormat(PointCodeFormat arg0) {
+ public void setRoutingLabelFormat(RoutingLabelFormat arg0) {
// TODO Auto-generated method stub
}
=======================================
--- /service/src/main/config/jboss-beans.xml Thu Aug 23 04:55:03 2012
+++ /service/src/main/config/jboss-beans.xml Fri Aug 24 04:14:37 2012
@@ -23,8 +23,8 @@
<!-- MTP3 Properties -->
<!-- Define MTP3 PointCode Format -->
<!-- ====================================================================
-->
- <bean name="PointCodeFormat"
class="org.mobicents.protocols.ss7.mtp.PointCodeFormat">
- <constructor
factoryClass="org.mobicents.protocols.ss7.mtp.PointCodeFormat"
factoryMethod="getInstance">
+ <bean name="RoutingLabelFormat"
class="org.mobicents.protocols.ss7.mtp.RoutingLabelFormat">
+ <constructor
factoryClass="org.mobicents.protocols.ss7.mtp.RoutingLabelFormat"
factoryMethod="getInstance">
<parameter>ITU</parameter>
</constructor>
</bean>
@@ -40,8 +40,7 @@
</constructor>
<property name="persistDir">${jboss.server.data.dir}</property>
<property name="transportManagement"><inject bean="SCTPManagement"
/></property>
- <property name="pointCodeFormat"><inject bean="PointCodeFormat"
/></property>
- <property name="slsLength">4</property>
+ <property name="routingLabelFormat"><inject bean="RoutingLabelFormat"
/></property>
</bean>
<bean name="M3UAShellExecutor"